Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8230879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:16:58+00:00 2026-06-07T17:16:58+00:00

I want to simulate a click, $(#genStats).trigger(click); every time I refresh the page window.location.reload()

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:17:00+00:00Added an answer on June 7, 2026 at 5:17 pm

    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:

    function isFirstVisit() {
        if (document.cookie.indexOf('beenhere') === -1) {
            // cookie doesn't exist, create it now
            document.cookie = 'beenhere=1';
            return true;
        }
        return false;
    }
    
    $(document).ready(function(){
        if (!isFirstVisit()) {
            $("#genStats").trigger("click");
        }
    });
    

    And to remove the cookie on your other pages:

    function removeCookie(sKey) {  
        if (!sKey || !this.hasItem(sKey)) { return; }  
        var oExpDate = new Date();  
        oExpDate.setDate(oExpDate.getDate() - 1);  
        document.cookie = escape(sKey) + "=; expires=" + oExpDate.toGMTString() + "; path=/";  
    }
    removeCookie("beenhere");
    

    Here’s a good resource on document.cookie

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple buttons on a page and I want to simulate a click
I want to Simulate a button click via JavaScript using a button's value, not
Let's say I've got a window for which I want to simulate a mouse
I want to simulate a click to an anchor tag with all extras like
I want to simulate the Right click/Update service reference command in a VS2010 addin.
I want to simulate a block dialog like window.alert() , window.confirm() , or window.prompt()
Is it possible to click programmatically a location in another window without moving the
I want to simulate many key press events. I found a solution by using
I want to simulate stroking a carpet, so you would have a graphic of
I would want to simulate the behavior of a table with div. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.