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

原文地址:https://www.cnblogs.com/deryck/p/4506937.html