iframe - HTML Renders in IE7 but not in Firefox or Chrome -
In IE 7, & lt; Iframe & gt;
renders, but the following html in Firefox or Chrome?
var content = "& lt;; DOCTYPE html public \" - // WAPFORUM // DTD XHTML mobile 1.2 / n \ "\" http://www.openmobilealliance.org/tech /DTD/xhtml-mobile12.dtd\">
body style = \ "background-color: # 0C0C0C; Color: #FFFFFF \ "& gt; Please enter credentials & lt; form name = \" dynamic format \ "& gt; & lt; ul class = \" edgetoedge \ "style = \" background-color: # 0C0C0C ; <"> div id = \" errorDiv \ "style = \" color: red \ "& gt; & lt; / div & gt; & lt; / li & gt; & lt; ; Li & gt; & lt; Input id = \ "Phone number: _min langnet \" type = \ "hidden \" value = \ "16 \" /> gt; gt ; & lt; script & gt; ..... var dynamicFormIframe = document GetElementById ('dynamicformIfre'); DynamicFormIframe = (dynamicFormIframe.contentWindow)? DynamicFormIframe.contentWindow: (dynamicFormIframe.contentDocument.document)? DynamicFormIframe.contentDocument.document: dynamicFormIframe.contentDocument; dynamicFormIframe.document.open (); dynamicFormIframe.document.write (Content); .... & lt; / sript & gt; & lt; body & gt; & lt; iframe id = "dynamicFormIframe" src = "" & gt; & lt; / F >
contentDocument.document
is rubbish; That segment will never be taken, Chrome will not support the non-standard contentWindow
property, will come back to use the contentDocument
, which will be ContentWindow
is a different object.
You only want the document, not by the window, so go to the standard contentDocument
first, and go back to the window to IE only where it is not supported Is:
var iframe = document.getElementById ('dynamicformIfre'); Var idoc = 'contentDocument' in iframe? Iframe.contentDocument: iframe.contentWindow.document; Idoc.open (); Idoc.write (content); Idoc.close ();
(In your example there are many obvious typo such as mismatched tags, JS is divided on string lines and there is a distorted theory, is this a copy-paste error?)
Comments
Post a Comment