Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Window.close without warnings

Posted on 2008-10-15
3
Medium Priority
?
1,173 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

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

636 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