0

I have a page with a iframe tag, that is loading another page with different domain.

<body>
   <iframe class="test" src="http://google.com" width="100%" height="100%"></iframe>
</body>

I want to add a class with jQuery to the page that is running in my iframe. (For example, in google.com I want to add a border to google logo.)

I tried this js code, but it dose not work.

$("iframe").contents().find(".google_logo").css({"border":"2px solid red;"});

Thank you very much.

Adriano Silva
  • 2,518
  • 1
  • 17
  • 29
Vahid Najafi
  • 4,654
  • 11
  • 43
  • 88
  • You cannot access content of iframe from different domain, this would cause all sorts of security issues – juvian Oct 09 '14 at 18:57
  • It's not possible. An iframe is just a designated area on your page that displays another page, the content of the iframe is not editable unless you have access to the files(in which case you would still need to make the changes on the source of the iframe and not the page that embeds the iframe). – APAD1 Oct 09 '14 at 18:58
  • Imagine that somebody logged into webmail, received and followed the link to the page, which opens in iframe the webmail (session still alive) of that somebody and doing whatever it wants with his emails )) Worse, it can be a bank account and so on.. – Cheery Oct 09 '14 at 19:03
  • There are security issues in allowing javascript to access cross site iframe data. Since the web allows people to log into a site and remain logged in when they return to the site ... if cross site manipulation of data were allowed, bad sites could get access to private information. – Wayne Oct 09 '14 at 19:24

0 Answers0