简体   繁体   English

页面重新加载回到index.php

[英]Page reload goes back to index.php

I'm using this script within my website: 我在网站上使用此脚本:

<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>

When it is executed the current URL ( http://.../slider/Cycle2/cycle2-tile.php?selection=3%2C4) ) is not realoaded and appended with '#' but the index.php ( (http://.../#loaded) ) is loaded instead. 执行时,当前URL( http://.../slider/Cycle2/cycle2-tile.php?selection=3%2C4)不会重新加载并附加'#'而是index.php( (http://.../#loaded) )已加载。 Why does this happen and how can I fix it? 为什么会发生这种情况,我该如何解决?

Can you try this? 你可以试试这个吗?

<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>

Did you mean: window.location.href = window.location.href + '#loaded'; 您的意思是: window.location.href = window.location.href + '#loaded'; instead of window.location = window.location + '#loaded'; 而不是window.location = window.location + '#loaded'; ?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM