javascript - run function on frame when window finish load -
i want run function click on spesific id inside frame, make 2 html file , write script this
the main html index.html
<!doctype html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script type="text/javascript"> function autoclick(){ document.getelementbyid('framing').contentwindow.document.getelementbyid('trig').click(); } </script> </head> <body onload="autoclick();"> <iframe name="framing" id="framing" src="testing.html" frameborder="0" scrolling="no" height="1200px" width="100%"></iframe> </body> </html>
and 1 testing.html
<!doctype html> <html> <head> <meta charset="utf-8"> <script> window.onbeforeunload = function(){ return false; // stop redirecting. } </script> </head> <body> <div> <a id="trig" href='http://www.redirect.com/' target='iname'>home</a> </div> <iframe src="about:blank" name="iname" frameborder="0" scrolling="no" height="1200px" width="100%"></iframe> </body> </html>
so when index.html
finish load page, want function click on <a id=trig" href='http://www.redirect.com/' target='iname'>home</a>
on testing.html
inside frame framing
, when clicked, trig
load site http://www.redirect.com
contained inside iname
frame, site http://www.redirect.com
have script redirect tld site, put script preventing page break out iframe ` window.onbeforeunload = function(){ return false; // stop redirecting. }
this 2 html file hosted on same domain. when try run it, function click not triggered, can me?
thank you, , sorry bad english, not native language
Comments
Post a Comment