How to add JavaScript code into existing iFrame using jQuery?

前端 未结 8 2125
借酒劲吻你
借酒劲吻你 2020-12-13 08:13

I want to add a JavaScript snippet into an existing iFrame in the page using jQuery. I have the following code...

Code:

content = \"

        
8条回答
  •  既然无缘
    2020-12-13 08:30

    As the iframe runs as it's own window, you will have to also inject the import of the jquery.js file.

    
    

    EDIT: So I played with this a bit more and here is what I came up with.

    HTML

    
    

    JS

    $("#frame").attr(
       "src", "data:text/html;charset=utf-8," + 
       "" + 
       "" + 
       "
    Test" + "
    提交回复
热议问题