fixed window.location.origin useless in IE

Today I got a issue that window.location.origin returns undefined in IE 9 .

But we can fix this issue with following code:

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

 

and now the window.location.origin will return what we expect

posted @ 2015-05-15 22:08  青苔1943  阅读(294)  评论(0编辑  收藏  举报