Search code examples
javascriptjqueryhtmlframesframeset

JQuery and frame(set)s - why do they disappear?


When I use the console and I try to create an element with tag frameset, I get no result:

$('<div id="content" data-something="hello" />')
=> [<div id=​"content" data-something=​"hello">​</div>​]
$('<frameset frameborder="0" framespacing="0" marginwidth="0" marginheight="0" framespacing="0" border="0"></frameset>')
=> []

This behaviour persists across multiple JQuery versions (like 1.10.2, 2.0.0 and 1.2.6 etc.)

How can I read the 'frameborder' (for example) attribute from this frameset without having to build a parser by mself?

P.S. (If you wonder why I use frames) This line (or a line like this) is a response from an external (more or less) API that I cannot change. I would just like to read the information and go on.


Solution

  • I used a workaround:

    var sourceWithFrames = ...
    sourceWithFrames = sourceWithFrames.replace(/<frame/g, '<xyzFrame')
    // e.g. 
    var frameborder = $(sourceWithFrames).find('xyzFrameset').attr('frameborder')
    // and so on
    

    This is, in my opinion, the best way to approach this (and probably the only one...)