Is it possible to add a script in an iframe?

I was wondering if I can add / add javascript to an iframe that loads from an external webpage that is not on my website. is it possible to use jQuery or even simple javascript?

  <script>
  // i need some code here
  </script>
  <iframe src="http://www.xxx.xxx/" id="myiframe" />

Note: I do not want to replace the contents of the iframe, I just want to add a script

thank

+3
source share
3 answers

, ( ), . , script , , - keyhooking .

+10

iframe , .

+5

This is not possible due to security policy.

However, if you really want to do this and understand the security issues, you can try to find a solution, such as Ajax Cross domain

0
source

Source: https://habr.com/ru/post/1731374/


All Articles