views:

107

answers:

1

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.

+3  A: 

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();
wombleton
No, I mean how do I select or list the `FRAMESET` elements in the document? These are the container elements of `FRAME` or other `FRAMESET` elements. One reason that I want to do this is in order to use JavaScript to remove a `FRAMESET` from a document.
Derek Mahar
Yes, this is more like what I had in mind!
Derek Mahar
wombleton, please have a crack at the related question that I asked at http://stackoverflow.com/questions/2791706/iterate-over-framesets-with-xpath-expression-in-javascript.
Derek Mahar