Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing window without IE warning message

Status
Not open for further replies.

jms8142

IS-IT--Management
Dec 3, 2001
16
US
Hello,
right now I'm using a primary window (default.htm on the server) to launch a secondary window without any buttons as the first true page of the website. My problem occurs when I try to close the initial window, like so:

window.open(2nd page with no buttons, etc.)
document.close

I get the message "The web page you are viewing is trying to close this window. Do you want to close this window?"

I realize this is realted to the IE security level setting and can be overridden by lowering it. The problem is that this will be distributed across the company with many users with many different IE settings, so I'd like to find a way to avoid it completely.

Incidentally, this only happens when you try to close initial windows, i.e., not ones that have been launched by the window.open function.

I can either solve this, or find a way to hide all of these buttons and bars on the initial page.
 
<script>
function closer(){
self.opener = this
self.close()
}
</script> Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048
Tek-Tips Best Practices: FAQ183-3179
 
Same deal,
I can initiate the close, I just need to get rid of the warning &quot;The web page you are viewing is trying to close the window...&quot;
 
Ooopss - I misunderstood - try this.

main.htm
<script>
function newWin(){
window.open(&quot;newPage.htm&quot;,&quot;newWin&quot;)
}
function closer(){
self.opener = this
self.close()
}
</script>

newPage.htm
<body onLoad=&quot;window.opener.closer()&quot;>
Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048
Tek-Tips Best Practices: FAQ183-3179
 
the code is fine, the window does try to close, but IE still prompts the user. I guess this is more of a browser setting issue and perhaps cannot be resolved in code.
 
No actually I had the script a little while back to do this but I posted it some were decided it was obsolete, since I decided to eliminate my child window since you cant save and then backspace. And someone else asked me for that today and I looked and couldnt find it but I am going crazy searhing for it, and once I get you got it.

Code One
 
What version of what browser are you using?
Try this for pre-IE6 only, the other suggestion should work in IE6.

<html>
<head>
<title>Closing Windows</title>
<object id=&quot;closes&quot; type=&quot;application/x-oleobject&quot; classid=&quot;clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11&quot; VIEWASTEXT>
<param name=&quot;Command&quot; value=&quot;Close&quot;>
</object>
</head>


<body>
<a href=&quot;javascript:closes.Click()&quot;>Close the window</a><br>
</body>
</html> Hope I helped / Thanks for helping
if ((Math.abs(x)<10&&Math.abs(y)<10) && (((parseInt(Math.abs(x).toString()+Math.abs(y).toString())-Math.abs(x)-Math.abs(y))%9)!=0)) {alert(&quot;I'm a monkey's uncle&quot;);}
 
Someone forwarded this to me and it works! It looks to me like it's doing the same thing that's been suggested here, but I guess it's slightly different. Thanks for everyone's help here.

firstwindow = window.self;
firstwindow.opener = window.self;
firstwindow.close();
 

Hi jms8142 ,

You wrote in your last reply that the following is working:

firstwindow = window.self;
firstwindow.opener = window.self;
firstwindow.close();

Well, It didn't work for me !
I'm using IE 5 & 6

I would realy appreciat any help.

Thanx.

Lyla.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top