Document.location not changing webpage in IE9?

I am trying to redirect to another page in IE9 (9.0.3).

When I try to get / set document.location , or document.location.href , or window.location / window.location.href , I cannot do this. He does not make any mistakes.

I tried to check if the document objects and windows are installed, and they are, so I have no idea why the location object is "missing".

I tried to get document.URL and it works fine, but it is read-only.

Does anyone know what the problem is or how to achieve this in cross-browser mode?

+4
source share
5 answers

I also experienced the same problem, but found that adding

 window.event.returnValue = false; 

above the line in javascript before redirecting solves the problem.

+9
source

See this: http://social.msdn.microsoft.com/Forums/en/iewebdevelopment/thread/c864ae63-66f6-4656-bcae-86b0018d70c9

Apparently this is a caching error, you can solve it by adding a timestamp to the destination URL (i.e. using a unique URL each time).

+1
source

Your IE9 may have some security restrictions that prevent JavaScript from directing URLs. window.location.href = "" should work fine on IE9.

+1
source

Cache may be the reason, try:

  location.href = 'something.php? tmp =' + Date.parse (new Date ())

Hope this helps

0
source

You must use an absolute url:

var url = '/ section / page /';
var host = window.location.hostname;
window.location = 'http: //' + host + url;

Where url is the relative path to your page.

0
source

Source: https://habr.com/ru/post/1382732/


All Articles