[thelist] Javascript in IE problem

James Hardy evolt at fraggle-rock.org.uk
Mon Oct 1 06:11:13 CDT 2001


I am trying to write a page where the user can select something from a
dropdown box and if it is not there then they can press a button which
will open up a pop up window that will get the information they want added
and then add it to the list on the original page.

I have tryed using the window.opener property whcih although works fine in
Mozilla 0.9.4 on Win2k it produces the error "The server threw an
exception" in Internet Explorer 5 on Win2k and also IE6 on Win2k.

I guess it is something to do with security. Any ideas?

(note this is designed to be used on an intranet of machines running IE5
or 6 on Win2k so patches or setting can be changed however we can't change
to Netscape as we have way too much legacy IE specific code)

Here's the code for the two pages I have written:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML lang=en-GB>
<HEAD>
<TITLE>Test</TITLE>
</HEAD>
<BODY>
<Form name="frm">
<SELECT name="sbox">
<OPTION value="ABCDEF">ABCDEF</OPTION>
<OPTION value="GHIJKL">GHIJKL</OPTION>
<OPTION value="MNOPQRST">MNOPQRST</OPTION>
</SELECT>
</FORM>
<BUTTON onclick="javascript:window.open('addopt.htm',
'addopt')">ABC</BUTTON>
</BODY>
</HTML>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML lang=en-GB>
<HEAD>
<TITLE>Test 2</TITLE>
<script language="Javascript" type="text/javascript">
function addopt(txt, valu){
	var newOpt  = new Option(txt, valu);
	var selLength = window.opener.document.frm.sbox.length;
	window.opener.document.frm.sbox.options[selLength] = newOpt;
	window.opener.document.frm.sbox.options[selLength].selected = true;
}
</SCRIPT>
</HEAD>
<BODY>
<BUTTON onclick="javascript:addopt('New Option', 'New Option')">New
Option</Button>
<BUTTON onclick="javascript:addopt('Wibble',
'wobble')">Wibble-Wobble</Button>
</BODY>
</HTML>

Please Help

James Hardy







More information about the thelist mailing list