Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How do I suppress " Are you sure you want to navigate away from this page" message through code

Posted on 2009-12-31
18
Medium Priority
?
353 Views
Last Modified: 2013-09-24
I am closing the browser through Java Script. When I do so I am getting a message from the IE asking me "Are you sure you want to navigate away from this page?" . I want to suppress this message either through HTML/Java Script/jquery. Please help.
0
Comment
Question by:creditpointe
  • 5
  • 4
  • 3
  • +3
16 Comments
 

Author Comment

by:creditpointe
ID: 26152686
Ref ths image for above question.
InternetExplorer-Image.JPG
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 26152706
do
window.onbeforeunload = null;
window.onunload = null;

have you checked this link
http://userscripts.org/topics/35250
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 26152719
It can't be done any more. Javascript will not return that message only when the window was opened by using a window.open. Javascript cannot close a window it didn't open without prompting for confirmation. You used to be able to fool i by setting the windows current opener to something other than null but that is no longer the case with IE 8.

Cheers,

Lee
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 26152761
And we are clapping our hands that web site creators no longer can mess with our main browser window.
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 26281730
A solution wasn't provided as there isn't one.  The question was correctly answered it just wasn't the answer that was wanted so I object to the question being deleted.
0
 

Author Comment

by:creditpointe
ID: 26281787
lsavidge,
The team here is still exploring a few things. Let's keep this open for a while then.


0
 

Author Comment

by:creditpointe
ID: 26330217
ModEErf:,
Thank you.
0
 
LVL 58

Expert Comment

by:Gary
ID: 39503944
I've requested that this question be closed as follows:

Accepted answer: 500 points for lsavidge's comment #a26152719

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 39495310
Actually. The horrible hack still worked in IE8
0
 
LVL 7

Accepted Solution

by:
dimmergeek earned 2000 total points
ID: 39503932
You can do this.
I do it all the time here at work.
If you want to close a single window that is open without the annoying confirmation, do this:

attach this to your link, button or whatever:

<script type="text/javascript" language="javascript">
        window.open('exit.htm', '_parent');
</script>

Open in new window



exit.htm should only have this:

<script type="text/javascript" language="javascript">
        window.close();
</script>

Open in new window


This works through IE8 and modern versions of Chrome and FF.
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 39504366
I think the original question was asking about closing a window that wasn't opened via a script. You can close any window you open with a script without a confirmation, but you cannot close a browser window that wasn't opened via a script without you being prompted. The loophole in IE was considered a hack and a security risk which is why it no longeer works.
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 39505107
I've had another look at the proposed solution in #a39503932 from dimmergeek. Now I've had time to sleep on it I see it now.

So, this opens a new page which is designed to close itself but it opens it in the _parent frame, which if the page is the top frame will act as if it is _self but then it immediately closes itself. As the page was opened via a script, the page will close without warning.

Indeed, to confirm it to myself, I tested it and it does exactly that. Ingenious!

I stand firmly corrected. Points should be awarded to dimmergeek and not me as that solution does work.

It feels dirty, but I like it!
0
 
LVL 7

Expert Comment

by:dimmergeek
ID: 39506069
Thanks lsavidge.
I've been using this dirty liittle trick for a long time.
I have several web pages that are automatically called to perform database updates and I needed a way to ensure that they closed and didn't leave open sessions.
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 39506109
I'll be adding this baby to my knowledge base on here.
0
 
LVL 7

Expert Comment

by:dimmergeek
ID: 39506173
:-)
0
 
LVL 7

Expert Comment

by:dimmergeek
ID: 39517848
Thank you.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

575 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question