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
238 views
in Technique[技术] by (71.8m points)

javascript - How to reload a web page on CodePen full page view by clicking a button

$("#quoteButton").on("click", function() {
    location.reload();
});

I worked on a 'Random Quote Machine' from Free Code Camp web site via NetBeans IDE 8.2 and this code works well, but when I paste it on CodePen for some reason it doesn't work on CodePen full page view. Is there a way that I can make a page reload when I click on a button on CodePen full page view anyway?

In Debug mode view on CodePen it's working. Here's a link to my CodePen: https://codepen.io/NemStep/pen/pdmowz

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

This is an alternative to location.reload.

The parameter of go is the page index, in this case, 0 is the current page.
For instance, go(-2) would go 2 pages back in the history.

$("#quoteButton").on("click", function() {
    history.go(0);
});

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

1.4m articles

1.4m replys

5 comments

56.9k users

...