I want to simulate a click,
$(“#genStats”).trigger(“click”);
every time I refresh the page
window.location.reload()
but not on the initial page load.
What’s the easiest way of doing this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Check out this other SO post: Check if page gets reloaded or refreshed in Javascript
The catch here is that this detects if it is the first time the user has landed on the page. So if they land there and refresh, you will get the desired effect. If they leave and come back, however, it will treat it the same as a refresh. If this is unacceptable, you will need to have a script on all of your other pages that clears this cookie.
Here’s what you would do in your case:
And to remove the cookie on your other pages:
Here’s a good resource on
document.cookie