IE does not implement window.location.origin
. And JSON.stringify()
is apparently ignoring properties whose value is undefined
(which its MDN documentation says it will do).
Run this jsFiddle in IE to see: http://jsfiddle.net/jfriend00/MP68r/
You can work around the issue by using other properties of window.location
depending upon exactly what you want to do with that info.
You could use this as an alternative:
location.href.match(/(^.*?\/\/.*?)[\/$]/)[1].toLowerCase();
This will return the part before the first slash in the path which is basically what the origin is. It is converted to lower case since domain names and protocols are case insensitive so this makes for a canonical comparison.