General discussion

Locked

Close window without error

By sonnaccino ·
I don't want the "do you want to close" error.
Here's my code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--
setTimeout('self.close()',5);
//--></SCRIPT>
</HEAD>

</SCRIPT>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>

</head>

<body onLoad="MM_openBrWindow('LobbyCam2.htm','LobbyCam','width=250,height=250')">

</body >

</html>

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by sonnaccino In reply to Close window without erro ...

Point value changed by question poster.

Collapse -

by softcorp.us In reply to Close window without erro ...

Hello Sonna...

By design, a web browser is only supposed to allow JavaScript to close a window that was created by JavaScript. So, as coded, your page should not be able to close itself. There are exceptions. Netscape 6 and Opera allow it. And, you can trick Internet Explorer into allowing it by using the trick that appears below (see ADDED BY STEVE in your code).

Does this achieve your objective?

-----Steve Jackson

CEO/CSA
Software Corporation (Softcorp)
http://www.softcorp.us/probono
Advanced pro bono tools and utilities free for personal use

---

The modified code is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--

// ADDED BY STEVE
window.opener = '';
// ADDED BY STEVE

setTimeout('self.close()',5);
//--></SCRIPT>
</HEAD>

</SCRIPT>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>

</head>

<body onLoad="MM_openBrWindow('LobbyCam2.htm','LobbyCam','width=250,height=250')">

</body >

</html>

Collapse -

by sonnaccino In reply to

Thanks a million!

Collapse -

by sonnaccino In reply to Close window without erro ...

This question was closed by the author

Back to Desktop Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums