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

Popular posts from this blog

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -