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.
views:
107answers:
1
+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
2010-05-06 23:08:55
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
2010-05-06 23:21:02
Yes, this is more like what I had in mind!
Derek Mahar
2010-05-07 20:46:48
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
2010-05-07 21:09:47