LoginSignup
3
4

More than 5 years have passed since last update.

IFrameの中に<script>を実行する

Posted at
<script type="text/javascript">
    function runScript() {
        var s = document.createElement("script");
        s.type = "text/javascript";
        s.src = "http://somedomain.com/somescript";
        var iframe = document.getElementById("iframeid");

        var iframeDoc = iframe.document;
        if (iframe.contentWindow)
            iframeDoc = iframe.contentWindow.document;
        iframeDoc.body.appendChild(s)
        iframeDoc.open();
        iframeDoc.writeln(content);
        iframeDoc.close();
    }
</script>
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4