admin管理员组文章数量:1431420
How can I list all FRAMESET
elements in an HTML document using JavaScript? I believe it to be possible to select these elements in the DOM tree because the DOM Inspector plugin for Firefox is able to list all the FRAMESETS
in a page.
How can I list all FRAMESET
elements in an HTML document using JavaScript? I believe it to be possible to select these elements in the DOM tree because the DOM Inspector plugin for Firefox is able to list all the FRAMESETS
in a page.
2 Answers
Reset to default 5There's a window.frames
collection, if that's what you mean.
EDIT:
Ah. For blowing away all frameset
elements, getElementsByTagName
:
var framesets = document.getElementsByTagName('frameset');
for (var i = 0; i < framesets.length; i++) {
// optional test for whether framesets[i]'s hatesFreedom attribute is true or false
framesets[i].parentNode.removeChild(framesets[i]);
}
Or jQuery, obviously:
$('frameset[hatesFreedom=true]').remove();
try
{
//window.top.frames[0]
alert(for i in window.top.frames) {alert('window.top.frames = '+i);}
alert(for i in window.top.frames[0]) {alert('window.top.frames[0] = '+i);}
}
catch (err)
{
//top frame is not your domain, break out of frames.
top.window.location = 'http://localhost/';
}
本文标签: domIterate over framesets in JavaScriptStack Overflow
版权声明:本文标题:dom - Iterate over framesets in JavaScript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745570635a2664025.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论