2016年6月25日 星期六

[javascript] location.origin not work on IE

 javascript    trouble-shooting    IE  



▌Problem


window.location.origin not works on some IE.



How to solve it


js

Use window.location.protocol, window.location.hostname, window.location.port to replace window.location.origin.

if (!window.location.origin) {           
window.location.origin = window.location.protocol + '//' + window.location.hostname + (window.location.port ? (':' + window.location.port) : '');
        }

var redirectUrl = window.location.origin.concat("/Area/Control/Edit", "?id=" + id);


沒有留言:

張貼留言