2011/05/20

jquery 改iframe content

有時逼不得已要用到iframe, 而iframe 入要的內容又想改wo
咁點做好呢?

以下方法只適用於same domain, protocol and port~!

//HTML
<iframe src="" frameborder="0" scrolling="no" id="iframe1" />

//JS
//找出header然後remove
$("#iframe1").attr('src', 'someURL');

$('#iframe1').live('load', function (){
    $("#iframe1").contents().find("div.header").remove();
});

沒有留言:

發佈留言