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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:14:20+00:00 2026-06-04T06:14:20+00:00

What I want to do is, to fire some function, only when user tries

  • 0

What I want to do is, to fire some function, only when user tries to close browser window by clciking on x button. But not on refresh, “back” button click events like following function does.

$(window).unload( function () { alert("Bye now!"); } );

So is there any way to achieve this? Thx in advance

  • 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-04T06:14:22+00:00Added an answer on June 4, 2026 at 6:14 am

    you could try forcing the user to a default location hash of #default as soon as they load the page. Then, if the person navigates back with the back button you can detect this with either a timer or the window’s “popstate” event. Then, you could do something at this point like send them to another url.

    In this way you could detect a window CLOSE with the “onbeforeunload” event and a back button press with the method mentioned in the last paragraph. Messy but it works.

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

Sidebar

Related Questions

Onsubmit I want to fire fancybox popup I need only to show the fancybox
I want to let TextBox control TextChanged event fire only when there are more
I have some problems with ASP.NET page cycle. I want to fire event when
I want to execute some function on all class elements. How can i do
i want to fire an event manually using c#. For instance, say if i
I have a periodically_call_remote that I want to fire right away (as if the
I have several sql queries that I simply want to fire at the database.
I have a Data grid with DatagridComboBoxColumn , and i want to Fire Event
i have 2 divs next to each other i want mouseleave to fire when
I want to have a generic event that I can fire that will take

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.