This is my situation.
The main page:
<script type="text/javascript"> function load_frm() { if($.browser.msie == true) { var frame = document.getElementById('frm'); frame.contentWindow.document.write(patch_html); } else { $("#frm").attr('src', "data:text/html;charset=utf-8," + escape(patch_html)); } } </script>
<html> <body> <input type="button" onclick="load_frm()"> <iframe id="frm"></iframe> </body> </html>
the patch_html contain $(document).ready which is need to fire after iframe loaded completely to change some element style inside the iframe .
jquery is included in header of patch_html. This code worked fine in firefox but not in IE.
The reason why I had to use write (for IE) and attr('src', "data:text/html...") is the html doesn't have the script to change some element style , it only injected in some certain conditions
I'm tried iframe's onLoad but it doesn't work. it fired before the resource loaded completely.
I founded the answer: javascript-how-to-load-dynamic-contents-html-string-json-to-iframe
I think the problem is
iframedoc.open(); iframedoc.writeln(patch_html); iframedoc.close();
the document need to open/close probably.
Probably use:-
$('iframe#frm').load(function() {/*do something here*/});
I founded the answer: javascript-how-to-load-dynamic-contents-html-string-json-to-iframe
I think the problem is
iframedoc.open(); iframedoc.writeln(patch_html); iframedoc.close();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.