override location.assign or location.replace
<p>Im trying to override the location.assign function, so that i can ensure that the urls set will always be absolute. But i cant seem to get it to work. With Xmlhttprequest.open it work fine like this:</p>

<pre><code>var oldOpen;
oldOpen = XMLHttpRequest.prototype.open;

// override the native open()
XMLHttpRequest.prototype.open = function(){

    //Prepend our proxyURL
    arguments[1] = prependURL+arguments[1];

    // call the native open()
    oldOpen.apply(this, arguments);
}
</code></pre>

<p>But for location.assign it does not work. This is what i try:</p>

<pre><code>var old;
old = window.location.assign.prototype.constructor;


window.location.assign.prototype.constructor = function(){
    console.log('dd');
    console.log(arguments);
            alert('ff');
}

old.apply(this,arguments);
</code></pre>

<p>When i run this code it get </p>

<pre><code>"Uncaught TypeError: Illegal invocation"
</code></pre>

<p>Im using Chrome for testing.</p>

<p>Any ideas?</p>

<p>BR/Sune</p>
