i running chrome --disable-web-security
on. need dynamically pick url, display frame contents when loaded, , know when frame has finished loading.
i love know when frame has loaded, and when every css etc/ have loaded.
test page:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html style="height: 100%" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta http-equiv="cache-control" content="no-cache" /> <meta http-equiv="pragma" content="no-cache" /> <title>the title</title> </head> <script type="text/javascript"> document.addeventlistener("domcontentloaded", function(event) { console.log("main content loaded!"); // iframe , iframe's window var iframe = window.frames[ 0 ]; var iframewindow = iframe.window; var iframedocument = iframe.window.document; // doesn't work iframe.addeventlistener('load', function( e ) { console.log("iframe loaded!"); }); // doesn't work iframedocument.addeventlistener('load', function( e ) { console.log("iframe loaded!"); }); // doesn't work iframewindow.addeventlistener('load', function( e ) { console.log("iframe loaded!"); }); iframewindow.onload = function(){ console.log("iframe loaded!"); }; iframewindow.location = "http://www.google.com"; }); </script> <!-- note: eventually, changing "url" change iframe source --> <body style="height:90%;"> <p>app</p> <form> <input name="url" type="text" size="20%" value="http://"> </form> <div id="frame" style="height:100%"> <iframe style="width: 100%; height:100%;" src=""> </div> </body> </html>
how can this?
i try first of wrapping js in window.onload
make sure javascript firing @ right time.
window.onload=function(){ // confirm iframewindow correctly pointing element iframewindow.onload=function(){ console.log('laoded') }; };
if doesn't work , give iframe id
<iframe id="myiframe" style="width: 100%; height:100%;" src=""> window.onload=function(){ var ifr=document.getelementbyid('myiframe'); iframewindow.onload=function(){ console.log('laoded') }; };
this should fix it, check console errors, have done before , worked , if both don't fix there else outside code going on
notice attached iframe , not window of iframe
Comments
Post a Comment