How to inject JavaScript into iframe tag in this example we learn how to isert javascript function inside iframe. <p><button id="btn">run js</button></p> <iframe id="iframe"></iframe> <script type="text/javascript"> document.getElementById("btn").addEventListener('click', function runcode(){ var js_code="<script>document.write('hello')</\script>" var doc = document.getElementById('iframe').contentWindow.document; doc.open(); doc.write(js_code); doc.close(); }); </script> © Manajmnt code Share to : ☷✎ Comments Subscribe to: Post Comments (Atom)
Comments
Post a Comment
message