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 8427929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:54:49+00:00 2026-06-10T04:54:49+00:00

How can I detect if a user has any intention to leave his current

  • 0

How can I detect if a user has any intention to leave his current page and redirect to any page from my website is their any javascript function that can handle this event I have more than 25 links in my page

<script type="text/javascript">
if(//user clicks a link )
 confirm("do you want to continue ?"); 

</script>

Is their any javascript function that can check if the user click on any link on the page

  • 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-10T04:54:51+00:00Added an answer on June 10, 2026 at 4:54 am

    This code will intercept all clicks on links in your page.

    $("a").click(function() {
        // this.href will be the href of the link they clicked on
        // return false from this function if you want to abort the click on the link
    });
    

    FYI, unless there are very special circumstances in your page, it’s kind of obnoxious to force a user to confirm that they actually want to go to the link they just clicked on. Can you imagine how terrible the web browser would be if you had to confirm every click.

    There is also a generic way to prompt if the user wants to leave your page using the onbeforeunload event.

    window.onbeforeunload = function(e) {
        return 'Are you sure you want to leave?';
    };
    

    Note: this is also obnoxious unless there are very special circumstances.

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

Sidebar

Related Questions

I want to have a 404 page that can detect if a user has
How can I programmatically detect whether the current user has CREATE TABLE permissions in
I'm wondering wether there's a Javascript way to detect wether a user has any
Is there any way I can detect when my page has been set as
How can I detect if the user has just downloaded the application and opened
How can I detect the site the user came from before accessing mine in
Can you please tell me if there is any library/API to detect if user
User can came from web or from devise (Android|iPhone|iPad|iPod) How correctly detect it?
Is there any way I can detect if the window got refreshed by user
How can I detect if user has an app, like echofon or twitter for

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.