Forum Moderators: open

Message Too Old, No Replies

Popup Window Auto Close Problem

         

travelby2um

12:42 am on Feb 23, 2005 (gmt 0)



I have glossary, help and information windows on my site. The windows open and focus, then automatically close when the user clicks and puts focus's on the parent window again. The current method I am using does not degrade gracefully if the users browser has JavaScript disabled. Attempt 1: doesn't work at all but should. Attempt 2: the auto close doesn't work.
Here is code for test pages showing the 2 problems I have, just can't see the solution. Would appreciate any help offered but want to keep the solution valid xhtml 1.0

Code for test_script.html page


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Test Popup Scripts</title>
<script language="JavaScript" type="text/javascript">
<!--
var MessWin = '';
function check_MessWin() {
if (!MessWin.closed && MessWin.location) {
MessWin.close();
}
}
var FullWin = '';
function check_FullWin() {
if (!FullWin.closed && FullWin.location) {
FullWin.close();
}
}
/* GLOSSARY NEW WINDOW */
function popup_help(x){
MessWin = window.open('/test_popup.html#'+x, 'MessWin',
'toolbar=0, scrollbars=1, location=0, statusbar=0, menubar=0, resizable=0, titlebar=1,width=500,height=500');
MessWin.focus();
} //-->
</script>
</head> <body onclick="check_MessWin(),check_FullWin()" onunload="check_MessWin(),check_FullWin()">
<h3>Test JavaScript</h3>

<b>CURRENT CODE:</b><br />
Here is my current code. Window opens and focus is set to the new window, when click or focus on parent new window closes.<br />
<a href="javascript:popup_help('sps')"; return true;>Help CURRENT CODE</a>

<br /><br />
<b>Attempt 1:</b><br />
When I try this, the window opens for a slit second then closes.<br />
I get this error in the Java Console :<br />
Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIControllers.removeController]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://navigator/content/navigator.js :: Shutdown :: line 736" data: no]<br />
<a href="/test_popup.html#sps" onclick="popup_help('sps'); return false;">HELP Attempt 1</a>

<br /><br />
<b>Attempt 2:</b><br />
When I try this., the window opens and focus is set to the popup, but click or focus on the parent window the popup just moves behind the parent window.<br />
<a href="/test_popup.html#sps" onclick="var MessWin=window.open(this.href, 'MessWin', 'width=500,height=500,scrollbars,resizable'); MessWin.focus(); return false;">HELP Attempt 2</a>

</body></html>


--------------------
Code for test_popup.html page

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Test Popup Page</title>
</head><body onLoad="window.focus()">
<a name="sps"></a>
<h3>Popup Page from Test JavaScript</h3>
</body></html>

orion_rus

8:49 am on Feb 24, 2005 (gmt 0)

10+ Year Member



you can't close window without javascript because any events (such as onclick onload is a javascript events)
I'm sorry but i didn't know any other ways