javascript - How to invoke a function in iframe using JS? -


how invoke function in iframe using js or how target iframe? i've tried using document.getelementbyid("myiframe"), didn't seem work. below basic form of html:

<html> <head> <script>     function runfunction() {         var win = document.getelementbyid("myiframe");     } </script> </head>     <body onload="runfunction()">         <iframe id="myiframe" name="myiframe" src="http://www.myothersite.com/"></iframe>     </body> </html> 

my other site has function named getevents() somehow invoke. appreciated.

you should able access iframe , invoke function using following:

// reference window in iframe id or name 'myiframe' var win = window.frames['myiframe'];  // invoke function in win win.getevents(); 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -