dom - Iterate over framesets in JavaScript? - Stack Overflow

How can I list all FRAMESET elements in an HTML document using JavaScript?I believe it to be possible

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.

Share Improve this question edited May 6, 2010 at 23:37 Derek Mahar asked May 6, 2010 at 22:59 Derek MaharDerek Mahar 28.4k46 gold badges127 silver badges181 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

There'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/';
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745570635a4633659.html

相关推荐

  • dom - Iterate over framesets in JavaScript? - Stack Overflow

    How can I list all FRAMESET elements in an HTML document using JavaScript?I believe it to be possible

    18小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信