If the links are relative, you could add a <base>
tag with jQuery.
$(function () {
var base = $("<base>", {
href: "http://www.your-new-website.com/"
});
$("head").append(base);
});
UPDATED
jQuery will not be the best solution because you will make 2 calls for every item...one for the initial load from the original server and one for the second load from the new server as jQuery changes the img
and css
links. Nonetheless, this should work.
function replaceDomain(href) {
var originalDomain = document.domain;
var newDomain = "mysite.com/view/content?url=http://" + originalDomain;
if (href.indexOf(originalDomain) == -1) href = "http://" + originalDomain + href;
return href.replace(originalDomain, newDomain);
}
$(function () {
//convert links
$('a').each(function () {
$(this).attr("href", replaceDomain($(this).attr("href")));
});
//convert imgs
$('img').each(function () {
$(this).attr("src", replaceDomain($(this).attr("src")));
});
//convert css links
$('link').each(function () {
$(this).attr("href", replaceDomain($(this).attr("href")));
});
});