[html5] Setting field in a different frame from javascript

Larry Martell larry.martell at gmail.com
Thu May 8 15:36:17 PDT 2014


On Thu, May 8, 2014 at 4:33 PM, Peter Borbely
<pborbely at fairfaxmedia.com.au> wrote:
> I suspect that the frame's DOM isn't loaded yet at the time your script is
> executed

Thanks, but I figured this out. I had to reference parent.frames
instead of window.frames.


>
>
> On 9 May 2014 05:49, Larry Martell <larry.martell at gmail.com> wrote:
>>
>> I have some javascript code, and I want to set the value of a field
>> that's in a different frame. The line in my js code to this is:
>>
>> window.frames.header_frame.document.getElementById('sort_key').value =
>> this.id
>>
>> When that line executes, I get an error:
>>
>> window.frames.header_frame is undefined
>>
>> But if I set a breakpoint on that line, and when it's hit access that
>> element from the js console it works:
>>
>> >>> window.frames.header_frame.document.getElementById('sort_key')
>>
>> <input id="sort_key" type="hidden" name="sort_key">
>>
>> What am I doing wrong in my script that is preventing me from
>> accessing that field?
>>
>> TIA!
>> -larry
>> _______________________________________________
>> Help mailing list
>> Help at lists.whatwg.org
>> http://lists.whatwg.org/listinfo.cgi/help-whatwg.org
>
>
>
> The information contained in this e-mail message and any accompanying files
> is or may be confidential. If you are not the intended recipient, any use,
> dissemination, reliance, forwarding, printing or copying of this e-mail or
> any attached files is unauthorised. This e-mail is subject to copyright. No
> part of it should be reproduced, adapted or communicated without the written
> consent of the copyright owner. If you have received this e-mail in error
> please advise the sender immediately by return e-mail or telephone and
> delete all copies. Fairfax Media does not guarantee the accuracy or
> completeness of any information contained in this e-mail or attached files.
> Internet communications are not secure, therefore Fairfax Media does not
> accept legal responsibility for the contents of this message or attached
> files.



More information about the Help mailing list