[Javascript] Mozilla valid javascript not working in IE

Luciano Ruete luciano at lugmen.org.ar
Mon Sep 6 21:33:44 CDT 2004


The code is simple, a parent opens a popup on demand, and the popup 
child reads a textbox, and add a option with the typed text in the 
parent's select object.
This code works ok in Mozilla and Firefox, but when i tested in Internet 
Explorer and Opera does not.

parent.html:

myPopup = '';
function openPopup(url) {
     myPopup = window.open(url,'popupWindow','width=640,height=480');
     if (!myPopup.opener)
         myPopup.opener = window;//also tested with self and this
     }


son.html:

var i = opener.document.forms[0].comboXXX.length;
myNewOption = new Option("nevo item" ,23, true);
opener.document.forms[0].comboXXX.options[i] = myNewOption;
window.close();


The code is generated whit php, here the php variables are hardcoded to 
simplify the script, also the function calls and the php if's.

I discovery that forms[0] and options[i], must be forms[1] and 
options[i+1] in Opera (i do not have IE to test, sorry linux fan :-).
But even with those changes, the parents select gets a new option, but 
whit no value, ie a blank select element. And the new option is not 
selected by default. Later test it in IE(a friend house) and same 
result: a new select blank option in the parent.
I test a hardcoded.html version like i send in this post, no php involved.

Attached father and son html's, with array starting at 1, working in 
opera with the blank option add.

Regards!

-- 
Luciano

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20040906/6286539b/attachment.html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20040906/6286539b/attachment-0001.html>


More information about the Javascript mailing list