如何通过单击按钮在CodePen全页视图上重新加载网页 [英] How to reload a web page on CodePen full page view by clicking a button

查看:254
本文介绍了如何通过单击按钮在CodePen全页视图上重新加载网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我通过NetBeans IDE 8.2在Free Code Camp网站上使用了随机报价机",该代码运行良好,但是由于某种原因将其粘贴在CodePen上时,它在CodePen的全页视图中不起作用.无论如何,当我单击CodePen全页面视图上的按钮时,是否可以重新加载页面?

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?

在CodePen的调试"模式下,它正在工作.这是我的CodePen的链接: https://codepen.io/NemStep/pen/pdmowz

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

推荐答案

这是location.reload的替代方案.

go的参数是页面索引,在这种情况下,0是当前页面.
例如,go(-2)将在历史记录中倒退两页.

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

这篇关于如何通过单击按钮在CodePen全页视图上重新加载网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆