?
Solved

Window.close without warnings

Posted on 2008-10-15
3
Medium Priority
?
1,170 Views
Last Modified: 2010-04-21
I open a window from
<a id='pm' href='mypage.asp'...><img ..></a>

I have a close button (image) on mypage.asp with
<img src="Close.gif" name="close" alt ="Close Window" style="cursor: hand" onclick="Window.close()">

But I'm getting the 'ol "The webpage you are viewing is trying to close the window...." prompt.
The window is opened by a link, why do I get this message? Can I do it without the prompt?

At the very least, I'd like my own message.

Thanks.
0
Comment
Question by:StevenJames
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
pwrBall earned 500 total points
ID: 22723802
Found this for you on the web:

I've had the same issue... and did a bit of research on my own to see if I could find a work-around for this.
I have created a simple testing example online to try out different methods of opening new windows and having them self-close:  http://sky.prohosting.com/savage25/AutoCloseExample.html
As you can see from the descriptions within it, IE6 and IE7 react differently in several of the cases.  Hence the "issue" that IE7 has created...
In particular, the one that is causing me issues is the FORM submission using a "_blank" target window.  It closes without confirmation in IE6, but does not in IE7.
A work-around that I discovered: IE7 may actually have become less secure when JAVASCRIPT redirects the current page (within the same window), and then this redirected-to site closes the window... the page then closes without any confirmation.  I was able to use this "bug" (?) to my advantage as a work-around to solve the problem.
Instead of calling "window.close()" to close the current window... do this:
window.open('close.html', '_self');
Where "close.html" contains:
<html><body>
<script language="JavaScript">window.close();</script>
</body></html>
This should work in both IE6 and IE7 to close the current window without confirmation.
I am currently using it in my application and it works well.
0
 
LVL 4

Author Closing Comment

by:StevenJames
ID: 31506414
I used to use this so I knew about it at one time. LOL! I need a physical memory upgrade!

Thanks!
0
 
LVL 4

Author Comment

by:StevenJames
ID: 22724140
Works like a charm.
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
Suggested Courses

752 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