1

I'm using and IFrame on my page. Once the page is loaded I got additional content from this iframe, it's simply html content but I cant access it with Jquery selectors. I know that dynamically added content is not 'Jquery-able'or may be with functions like live() but what I want is to hide part of it without the use of events.

So I would like the DOM to take account of it. Is it possible?

  • The content you're loading with the iFrame is basically a mirror of the code on somebody else's server. You can't change somebody else's code. So it's not possible. – Jean-Paul Jul 10 '13 at 10:00
  • @Jean-Paul Yes this is possible and is called ["cross-site scripting (XSS)"](https://en.wikipedia.org/wiki/Cross-site_scripting) – feeela Jul 10 '13 at 10:05
  • @feeela: But isn't that a vulnerability instead of a practical method? I mean I know it's possible but not for practical purposes right? – Jean-Paul Jul 10 '13 at 10:06
  • 1
    @Jean-Paul That depends on your point of view ;-) – feeela Jul 10 '13 at 10:12

2 Answers2

2

It is possible as long as the iframe content comes from the same server as not to conflict with the same origin policy. The following works as long as the content comes from the same server.

$("#iFrame").contents().find("#someDiv").removeClass("hidden");

Refer to this question:

jQuery/JavaScript: accessing contents of an iframe

Community
  • 1
  • 1
Adam
  • 2,204
  • 2
  • 15
  • 15
0

Not posible to access inside an iframe from outside via javascript. if your iframe is onside your domain, consider loading it via ajax.

monxas
  • 2,475
  • 2
  • 20
  • 36