Solved

Window.close without warnings

Posted on 2008-10-15
3
1,161 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
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
pwrBall earned 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Works like a charm.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now