javascript - $window.location.origin gives wrong value when using IE -
$window.location.origin
returns wrong value on ie.
the origin property returns protocol, hostname , port number of url.
example
url: http://localhost:8080/products/search
chrome: $window.location.origin
returns http://localhost:8080
ie: $window.location.origin
returns http://localhost:8080/products/search
how can have right value on ie?
you may need port number. if so, can use polyfill
if (!window.location.origin) { window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : ''); }
this polyfill part of modernizr.
Comments
Post a Comment