简体   繁体   中英

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. 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'; instead of window.location = window.location + '#loaded'; ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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