Bypass IE “The webpage you are viewing…” pop up

Is there a way to bypass the following IE popup box:

The webapge you are viewing is trying
to close the window. Do you want to
close this window? Yes|No

This is occurring when I add window.close() to the onclick event of an asp.net button control.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

In the opened popup write following

var objWin = window.self;
objWin.open('','_self','');
objWin.close();

Method 2

Your JavaScript code can only close a window without confirmation that was previously opened by window.open(). This is an intentional security precaution because a script running on a webpage does not own the window, and by closing it discards the browsing history in that window.

The workaround is to either have a “welcome page” or otherwise some sort of page that pops up the window you want to close with window.open in the first place, or to tell your users to modify their browser security settings to allow your application to close their windows.

Method 3

There is a hack for this.

for IE call:

window.open('close.html', '_self');

then in close.html all you need is:

<script>window.close();</script>

Since this essentially opens a popup, in the same named window, when the “new’ window opens, it has an “opener” and thus is allowed to close.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x