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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:40:50+00:00 2026-06-16T00:40:50+00:00

I am using following code so that if user closes the browser button it

  • 0

I am using following code so that if user closes the browser button it shows a confirmation box, whether to stay on page or not.

What I want to do is if someone closes the browser it should show an image, with “yes” or “no” options. When “yes” is clicked it should close the browser and if “no” is clicked it shouldn’t close the browser. The Image has to be shown in the same window not in any popup. Is it possible to do it or am I expecting too much from JavaScript?

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="text/javascript">
var exit=true;
    function confirmExit()
            {
            if(exit)
            {
            window.location.href = "?p=exit";
            }
            if(exit)
            return "Wait! Don't Leave Empty Handed!\n\nThank you for taking the time to check out our offer! Before you go we have a complimentary crash to help you succeed. Click the 'Cancel' or 'Stay On This Page' button if you're interested!";
            }
</script>
</head>
<body  onbeforeunload="return confirmExit()">
</body>
</html>
  • 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-16T00:40:51+00:00Added an answer on June 16, 2026 at 12:40 am

    You cannot change the onbeforeunload() default behaviour as it is native to each browser. You can only return a custom string.

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

Sidebar

Related Questions

Visual Studio 2008 I am using the following source code that compiles ok using
I have the following code that works without using throw however when I use
I came across the following code that compiles fine (using Visual Studio 2005): SomeObject
I am using Lazarus v0.9.30 (32 bit compiler). I have the following code that
In the following assembly code that I dumped out using objdump : lea 0x0(%esi,%eiz,1),%esi
I am using the following code to save values from a settings view that
I'm using the following code to update a record. Bad thing is that it's
I have a combobox that is bound to an enum using the following code:
I generate a vcard that I send to the client using the following code
I'm using the following code to attach an event to the submit button of

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.