Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 335
Nemanja Stepanović Avatar asked Jan 23 '26 07:01

Nemanja Stepanović


1 Answers

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);
});
like image 107
Stefano Spkg Gagliardi Avatar answered Jan 25 '26 19:01

Stefano Spkg Gagliardi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!