Is it possible to override somehow document.location.href ?
need override getter, ex.: alert(document.location.href); should return lets say "www.example.com" while real document location is www.stackoverflow.com...
don't know is it possible..
Is it possible to override somehow document.location.href ?
need override getter, ex.: alert(document.location.href); should return lets say "www.example.com" while real document location is www.stackoverflow.com...
don't know is it possible..
No, but...
In Ecmascript 5, there is support for getters/setters and you can spoof the document reference if accessed from within a scope which redefines it.
Proof:
(function (document) {
alert(document); // -> "spoofed document"
})("spoofed document");
Combined with accessors you can replace the document object. (Javascript 1.5 is needed for accessors.)
As others already have noted it is not possible to change the URL without reloading the page.
Note that you can the change the fragment identifier, i.e. the part in the URL after the hash (#) using document.location.hash, but that is probably not good enough for you.
Swap out "document" to another variable, edit it, and swap it back in.
var d = {}
for (var k in document) {
d[k] = document[k];
}
d["location"]="out of this world";
document = d;