AnApprentice
AnApprentice

Reputation: 111030

Having jQuery inside of an iframe modify the parent window

i have a page which has an iframe.

in the iframe, I want jQuery to remove an element from the patent page, so I'm trying:

parent.$('#attachment-134').remove();

But that doesn't work. Any ideas? thanks

Upvotes: 0

Views: 1633

Answers (1)

jAndy
jAndy

Reputation: 236092

Should be:

$(parent.document).find('#attachment-134').remove();

This of course only remains true, if the iframe and the parent have the identical domain. Otherwise the SOP (Same Origin Policy) would deny the access.

Example: http://jsbin.com/eqise5

Upvotes: 7

Related Questions