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

  • Home
  • SEARCH
  • 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 6107847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:14:00+00:00 2026-05-23T14:14:00+00:00

Possible Duplicate: Can you detect/redirect a back button press through javascript? I am developing

  • 0

Possible Duplicate:
Can you detect/redirect a back button press through javascript?

I am developing a small web application. In my application I must know when the user clicks the “back” button, so I can run some javascript code. Is there any such way to detect it?

thank you

  • 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-05-23T14:14:00+00:00Added an answer on May 23, 2026 at 2:14 pm

    Ok, so I discovered that the JS API cannot access the history object’s next property without elevated permissions, which got me thinking in another direction.

    Form fields are automatically fetched from the browser’s cache, thus holding historic data. while this is true, javascript code is run independently each time.

    So I created a small hidden field to hold a timestamp and compare it against the javascript’s generated datatime.

    Here is the code, I am sure it can be much better implemented, though time is short:

    $(document).ready(function () {
         var date = new Date();
         var clientMiliseconds = date.getTime();
         clientMiliseconds = roundTime(clientMiliseconds);
         var serverTimeStamp = $('#' + '<%= hfTimeStamp.ClientID %>').val();
         serverTimeStamp = roundTime(serverTimeStamp);
         alert(serverTimeStamp == clientMiliseconds);
    });
    
    
    function roundTime(time) {
        time = Math.floor(time);
         //since the server renders the time components a few seconds before the page is downloaded 
         //which also depends on where you assign the date on the serverside 
         //we've got a small inaccuracy of few seconds. we neglect these seconds, assuming that it would take the user
         //a few seconds to click the back button
    
         time = time / 10000;
         time = Math.floor(time);
         return time;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How can I pre-set arguments in JavaScript function call? (Partial Function Application)
Possible Duplicate: How can I detect the browser with PHP or JavaScript? I want
Possible Duplicate: Standard way to detect mobile browsers in a web application based on
Possible Duplicate: Can Read-Only Properties be Implemented in Pure JavaScript? I have an Object
Possible Duplicate: How can I access local scope dynamically in javascript? Hi all. We
Possible Duplicate: Can I use ASP.NET MVC together with regular ASP.NET Web forms Let's
Possible Duplicate: How to detect if JavaScript is disabled? I'm curious what other people
Possible Duplicate: Detect if an outgoing call has been answered How can I know
Possible Duplicate: How can I detect the encoding/codepage of a text file I've been
Possible Duplicate: How can I detect if a browser is blocking a popup? I

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.