I have a Javascript that changes the host in links to match the current development/test server.
Here's an example:
var ndomain = document.domain;
var mydomain = 'www.foo.com';
var alink = document.getElementsByTagName('a');
for (var i = 0; i < alink.length; i++) {
if (alink[i].href.length > 0){
if (alink[i].host.substr(0, mydomain.length) == mydomain){
alink[i].host = ndomain;
}
}
}
This changes references to http://www.foo.com/page.html to http://level1.test.foo.com/page.html.
This works in every browser I've tested except Safari (Mac or Win). I've searched and searched for information as to why and the closest reason I've come up with is the "same-origin policy".
Based upon my understanding of the same-origin policy, this should work because everything is under the foo.com domain. Could Safari be more strict in the fact that I'm going to a two level subdomain (e.g.level1.test)?
Can someone advise as to why this process doesn't work in Safari or how I can get it to work in Safari?
TIA!