var loc = document.location.toString().split('#')[0]; document.location = loc + '#' + anchor; 转载于:https://www.cnblogs.com/argenbarbie/p/8463020.html