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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:55:00+00:00 2026-06-12T07:55:00+00:00

I have MyPage.aspx html page (generated using ASP.Net). When user tries to navigate away

  • 0

I have MyPage.aspx html page (generated using ASP.Net). When user tries to navigate away from this page, I need to close the window – user should not be able to go back or navigate to another page.

When I used window.close() inside window.onbeforeunload event, it asks for a confirmation to the user. “The webpage you are viewing is trying to close the window. Do you want to close the window?” On clicking “No” the user can escape the close attempt. Is there any way to forcefully close the window without giving an option to the user?

Reference:

  1. How can I close a browser window without receiving the "Do you want to close this window" prompt?
  2. Html javascript to open new window and close current window
  3. "Unknown Exception" when cancelling page unload with "location.href"
  4. Display confirmation popup with JavaScript upon clicking on a link
  • 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-12T07:55:02+00:00Added an answer on June 12, 2026 at 7:55 am

    You can “trick” the browser like this:

    window.onbeforeunload = function() {
        window.open('', '_self', '');
        window.close();
    }
    

    It seems to work in chrome/safari/ie/ff: http://jsbin.com/olijig/1

    Firefox seems stubborn, but there might be another way to do the same in FF.

    I should probably say that this technique is in no way standard and I don’t recommend it at all, and this code might break in many browsers besides firefox.

    UPDATE

    It actually works in Firefox too (latest version), but not older versions (I tried 3.6.1). You need to do some more testing to confirm the browser compatibility.

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

Sidebar

Related Questions

I have this html code for embedding a video in an aspx page: <OBJECT
I have a page whose relative path is ~/pages/mypage.aspx. I tried using VirtualPathUtility.ToAbsolute(@~/pages/mypage.aspx) hoping
I am using asp.net MVC framework. On my page i have a dropdwonbox and
Hello Freinds I am new to this Asp.net MVC Control.. I have a page
I have an html form that looks like this: <form name=form_ method=post id=contactUs action=myPage.aspx
On my page I have: <%@ Page Language=C# AutoEventWireup=true CodeBehind=siteSettings.aspx.cs Inherits=APack.admin.siteSettings %> <!DOCTYPE html
I am using a tiny mce html editor in a aspx page but i
I have a ASP.NET (C#) web page in which I want to enumerate a
How do I go about rendering an asp.net control on a web page from
I have a web page named MyPage.aspx and two master page named Home.master and

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.