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

試著忘記壹切 提交于 2019-12-13 08:17:39

问题


$("#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


回答1:


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);
});


来源:https://stackoverflow.com/questions/47678907/how-to-reload-a-web-page-on-codepen-full-page-view-by-clicking-a-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!