Solved

Window.close without warnings

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

705 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