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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE 6 won't close window with window.close()

Status
Not open for further replies.

randyQ

IS-IT--Management
Apr 26, 2001
117
US
I am administering our Intranet site, and one of the things we have on our student sites, is a policy agreement page, that forces you to click on "I agree", then click "OK" in a verification window. This forces the user to at least see, and be aware of, our Internet use policies. When a user attempts to access a different website, either by typing in the address bar, or using a bookmark, the window is supposed to close. However, in IE 6 with all the latest updates, the browser alerts the user that the window is trying to close. If they choose to not close the window, then the browser goes right on to the website they typed in. I don't want IE to alert them when the window is trying to close. I want the browser to just shut down. If you want to see my code, the Intranet site is available to the public (against my wishes). The link to the Middle School Intranet site is here:
Thanks.
 
this is probably a bug exploit, and so is not guaranteed to work forever, but it usually works:

function closebrowser()
{
window.opener = self;
window.close();
}



=========================================================
while (!succeed) try();
-jeff
 
Nope jeff,
that did'nt work for me.

randyQ
window.close will not prompt if the window is opend in javascript, any other metd od opening a window will result in prompting.

Known is handfull, Unknown is worldfull
 
So, help me set this up, vbkris.

I would take my current page, and rename it, and create a blank page with the original name. Then, I would put a onLoad event in the body tag of the blank page that would relocate the window to the renamed page.

For ex.:

msindex.html=
<html>
<body onload=&quot;jumppage()&quot;>
<script>
function jumppage(){
window.location=&quot;msindex2.html&quot;}
</script>
</body>
</html>

msindex2.html=
<!--original page -->

Then, after that, my window.close() would work? Thanks.
 
vbkris,

what browser/OS are you using? works fine for me in WinNT [ NS7, Moz1.3, Phoenix 0.5, IE6SP1 ] and Win2k IE6SP1. Doesn't work with NS4.77.



=========================================================
while (!succeed) try();
-jeff
 
randyQ
try this:
<html>
<body onload=&quot;jumppage()&quot;>
<script>
function jumppage(){
window.open(&quot;msindex2.html&quot;)}
</script>
</body>
</html>

now try giviing window.close in msindex2.html



[jemminger]
i tried it in IE5.0, Win 2000.


Known is handfull, Unknown is worldfull
 
You could try this

Here's some code for a self close script, (without the IE message moaning about the web page is trying to close the window)
Code:
<html>
<head >
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Begin
function closeMe() {
father = window.self;
father.opener = window.self;
father.close(); 
}
// End -->
</script>
</head>
<BODY>
<BODY onLoad=&quot;parent.closeMe()&quot;>
</BODY>
</html>
[code]
 
yo,
but my client must have them.....


Known is handfull, Unknown is worldfull
 
Thanks for all the help. Here is the final code I used. If you all see a better way of doing this, then I am still open to suggestions.

<body onUnload=&quot;javascript:verifyagree()&quot;>

<script language=&quot;javascript&quot;>
var ok=0
function verifyagree()
{
if (ok == 0)
{
window.opener=self
window.close()}
else
location=&quot;** URL **&quot;
}

function agree()
{
var agreechoice=confirm(&quot;By Clicking on 'OK', you are confirming your agreement to the rules and regulation set forth by this district concerning proper Internet use.&quot;)
if (agreechoice)
{
ok=1
location=&quot;** URL **&quot;}
else
{
window.opener=self
window.close()}
}

function closebrowser()
{
window.opener=self
window.close()
}
</script>

** Insert User Agreement Here **

<a href=&quot;javascript:closebrowser()&quot;>I Do Not Agree</a>

<a href=&quot;javascript:agree()&quot;>I Agree</a>

</body>
</html>

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top