我在我的网站中使用这个脚本:
<script>
//refresh the page once to load slideshow correctly
setTimeout(function(){
if(!window.location.hash) {
window.location = window.location + '#loaded';
window.location.reload()}}, 1000);
</script>
执行时,当前URL (http://.../slider/Cycle2/cycle2-tile.php?selection=3%2C4)
)不会重新加载并附加'#',而是加载index.php ((http://.../#loaded)
)。为什么会发生这种情况,我该如何解决它?
你能试试吗?
<script>
//refresh the page once to load slideshow correctly
var currentLocation=window.location.href;
setTimeout(function(){
if(!window.location.hash) {
window.location = currentLocation + '#loaded';
window.location.reload()}}, 1000);
</script>
你的意思是:window.location.href = window.location.href + '#loaded';
而不是window.location = window.location + '#loaded';
?