Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
470 views
in Technique[技术] by (71.8m points)

javascript - 首页加载后一次刷新页面(One time page refresh after first page load)

I would like to implement a JavaScript code which states this: if the page is loaded completely, refresh the page immediately, but only once.

(我想实现一个JavaScript代码,该代码声明:如果页面已完全加载,请立即刷新页面,但只刷新一次。)

I'm stuck at the "only once":

(我被困在“只有一次”:)

window.onload = function () {window.location.reload()}

this gives a loop without the "only once".

(这给出了一个没有“只有一次”的循环。)

jQuery is loaded if this helps.

(如果这有帮助,加载jQuery。)

  ask by Martin translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I'd say use hash, like this:

(我会说使用哈希,像这样:)

window.onload = function() {
    if(!window.location.hash) {
        window.location = window.location + '#loaded';
        window.location.reload();
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...