0

このコードはうまく機能しlink[href]ます。

$("iframe").load(function() {
    $("iframe").contents().find("script[src], img[src], link[href], a[href]").each(function(i) {
        this.href = this.href.replace(/^http:\/\/www\.mydomain\.com/, "http://www.theotherdomain.com");
    });
});
4

1 に答える 1

1

これは、href属性を設定しようとしthis.href = ...たが、唯一の要素がhrefリンクであるためです。画像とスクリプトの場合、src属性を設定する必要があります。

于 2012-11-19T14:23:04.377 に答える