Soren Schimkat <> writes:
> IE crashes or tells me that the server threw an exception:
>
> window.opener.document.forms['formname'].elements['listname'].options[0]
> = new Option('foo', 'bar')
>
> The code works just fine in Firefox. Could someone give me at hint on
> what's wrong here?
Probably that you are adding an instance of Option from the current
document to a select from another document. I would try using the "Option"
constructor function from the other window, i.e., something like:
var otherWindow = window.opener;
otherWindow.document.forms['formname'].elements['listname'].options[0] =
new otherWindow.Options('foo','bar');
Not sure whether it works, though. My tests are inconclusive
To avoid this cross-page DOM scripting, you could put a function on the
original page to do the work, and just call it from the opened page.
<script type="text/javascript">
function addOption(text,value) {
document.forms['formname'].elements['listname'].options[0] =
new Option(text,value);
}
</script>
and then just do
window.opener.addOption('foo','bar');
in the opened window.
/L
--
Lasse Reichstein Nielsen -
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'