this is my html code :
<frameset rows="18,*" frameborder=0 framespacing=0>
<frame src="/zh-cn/MapS/MainTop/" noresize scrolling=no>
<frameset cols="0,*,210" name="menu">
<frame src="/zh-cn/MapS/MainLeft/" scrolling=no noresize>
<frame src="/zh-cn/MapS/Watch/" name="desk">
<frame src="/zh-cn/MapS/RightMenu/" scrolling=no noresize>
</frameset>
</frameset>
and this is the javascript code in on frame :
parent.parent.frames[2].frames[0]
i want to know which name is this frame ,
i do this :
console.log(parent.parent.frames[2].frames[0].nodename)
it show:
undefined
so what can i do ,
thanks
For example, this should work
window.frameElement.name
Also, if all you have is a reference to an element inside a frame and want to know the frame name this element belongs to:
document.getElementsByTagName("body")[0].ownerDocument.defaultView.window.frameElement.name
Why are all the answers here so complicated ?
The name of the current document (== frame name) can be obtained via:
var sName = window.name;
If the current document is the root document or if the parent document has not assigned a name to the child frame, sName will be an empty string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With