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");
});
});
This is because you try to set the
hrefattributethis.href = ...but the only element that hashrefis a link. For images and scripts, you have to set thesrcattribute.