开发者

Having jQuery inside of an iframe modify the parent window

开发者 https://www.devze.com 2023-02-09 23:24 出处:网络
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:

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

精彩评论

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