开发者

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.$('#att开发者_运维百科achment-134').remove();

But that doesn't work. Any ideas? thanks


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜