Solved

Window.close without warnings

Posted on 2008-10-15
3
1,164 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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
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.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
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)

828 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