views:

41

answers:

2

Possible Duplicate:
how to add code into a iframe

I want to add some javascript code into external iframe. How to do it ?

I want to actually add ads code into iframe pages ?

Please help me

+2  A: 

This can not be done, because iFrames from other domains cannot be accessed using JavaScript for security reasons.

From the MDC Docs:

Scripts trying to access a frame's content are subject to the same-origin policy, and cannot access most of the properties in the other window object if it was loaded from a different domain. This also applies to a script inside a frame trying to access its parent window. Cross-domain communication can still be achieved with window.postMessage.

Pekka
Also, putting your own ads on top of someone else's content is a total dick move.
ceejayoz
@cee that goes without saying. :)
Pekka
+2  A: 

This isn't possible across different domains. Otherwise it would be very easy to make a cross site scripting attack by including the target website inside an iframe on your site.

Qazzian