0

This code works great, it just only works on the link[href] and nothing else

$("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");
    });
});

1 Answer 1

1

This is because you try to set the href attribute this.href = ... but the only element that has href is a link. For images and scripts, you have to set the src attribute.

Sign up to request clarification or add additional context in comments.

1 Comment

I've done that with .find("script[src], img[src], link[href], a[href]")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.