Search code examples
javascriptfirefoxiframeparent

Parent iframe with FireFox doesn't work?


I'm trying to change de value of an input variable (located in the parent or main window) from an iframe. It works fine in IE8, Chrome or Safari, but not in FireFox...

This is my code:

parent.NameOfTheInputVariable.value=_value_;

What am I doing wrong? I've read that firefox doesn't accept the "parent" window... how can I access the main window?


Solution

  • The problem is not the parent, but assuming that there will be a global variable just because something has a name. That is a non-standard IEism that WebKit has adopted (although I think it may only work in Quirks mode, which is best avoided anyway).

    parent.document.getElementsByName('NameOfTheInputElement')[0].value = ...;
    

    … should do the job.