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.

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

本文标签: domIterate over framesets in JavaScriptStack Overflow