How to add JavaScript code into existing iFrame using jQuery?

前端 未结 8 2138
借酒劲吻你
借酒劲吻你 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:33

    You need to escape the /script. It apears.

    Do like google analitcs for instance

     $("#iframe").contents().find("body").append(decodeURI("**%3Cscript%3E** alert(2)  **%3C/script%3E**")); 
    

    replace the script and /script with this escaped ones

    Hope it helps.

提交回复
热议问题