Forum Moderators: open
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>
<?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>