Programatically replacing a frameset...
-
Wednesday, June 03, 2009 10:01 PMHere's a head scratcher for you gurus out there:
We have something similar to the "IE information bar" (implemented in Javascript/HTML) that needs to be displayed on pages with certain security flaws. We typically insert this into the document.body within our BHO - a relatively trivial task. However, for pages that have a FRAMESET instead of a body, there is no way to programatically insert our information bar, because framesets can't contain tags. Neither can we insert the "information bar" into the FRAME object(s) within the FRAMESET, since we have no assurance that the frames will span the display area of the browser (leading to an awkward looking truncated information bar). Is there any way that we can insert our "information bar" into the page and ensure it will always be displayed at the top? The catch is that we don't want to trigger a navigation event, so we'd have to use the DOM.
One idea we had was to try and save the DOM tree for the frameset, remove it from the document, splice in a body with an IFRAME, and re-insert the DOM tree from the frameset into the IFRAME. Similar to:
IHTMLDOMNode frameSetNode = frameSet->cloneNode();
document.frameset = null;
IHTMLBodyElement body = document.createElement("<BODY>");
IHTMLIFrameElement iframe = document.createElement("<IFRAME>");
iframe.document.appendChild(frameSetNode);
body.appendChild(iframe);
This obviously isn't working. Any suggestions?
All Replies
-
Tuesday, July 17, 2012 8:18 PM
Not sure if this is the issue. However the documentation for createElement states the following:
"In Microsoft Internet Explorer 4.0, the only new elements you can create are img, area, and option. As of Microsoft Internet Explorer 5, you can create all elements programmatically, except frame and iframe."
http://msdn.microsoft.com/en-us/library/aa752570(v=vs.85)
Thus when your attempt to create the IFRAME element fails.
-
Wednesday, July 18, 2012 2:55 PM
One idea we had was to try and save the DOM tree for the frameset, remove it from the document, splice in a body with an IFRAME, and re-insert the DOM tree from the frameset into the IFRAME.
I think you need make a deep clone of the frameset using cloneNode() method. This is clearly specified at MSDN:
"IHTMLDOMNode::cloneNode does not work on an IFRAME directly. You must call IHTMLDOMNode::cloneNode through the all collection. "
http://msdn.microsoft.com/en-us/library/aa704077(v=vs.85).aspx
Best regards, Sergey


