Wednesday, January 30, 2008

window frames property test

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<HTML>
<HEAD>
<TITLE>A frameset document</TITLE>
</HEAD>
<FRAMESET cols="40%, 60%" name="fs" id="frs">
<FRAME src="fm1.html" frameborder="0" name="fmn1" id="fmi1"/>
<FRAME src="fm2.html" frameborder="0" name="fmn2" id="fmi2"/>
</FRAMESET>
</HTML>
debug under firebug console:
>>> window
Window frames.html
>>> window.frames
Window frames.html
>>> window.frames[0]
Window fm1.html
>>> window.frames[1]
Window fm2.html
>>> window.frames[1].id
# => undefined
>>> window.frames[1].src
# => undefined
>>> window.frames[1].name
"fmn2"
>>> document.getElementById('fmi1')
<frame id="fmi1" name="fmn1" frameborder="0" src="fm1.html">
>>> document.getElementById('fmi1').id
"fmi1"

Object window has name propery, but has no id and src properties, so window.frames[1].src is undefined, we can get src value throught top window's element object, such as cument.getElementById('fmi1').id

No comments :