How does IE11 populate window.location.origin?
Asked Answered
T

1

8

I have an issue in a non production environment in Internet Explorer 11 where

window.location.origin is undefined.

However, in the production environment this value actually returns

window.location.origin = http://www.myproductionwebsite.com

This issue only exists in Internet Explorer and works fine in Chrome and Firefox across production and non production environments, which has lead me to believe its the way that the Chakra JavaScript Engine in IE11 populates origin.

I have also looked at the request and response headers across production and non production environment and all the parameters are identical.

How does Internet Explorer 11 calculate window.location.origin differently to Chrome or Firefox?

Tatiana answered 22/9, 2015 at 16:25 Comment(9)
What is the value of window.location.href in the test environment?Catchment
window.location.href in the test environment is the same as the URL at the top. I'm just wondering how IE11 obtains the origin as its undefined in the test env and http://www.myproductionwebsite.com in production. Maybe it uses DNS?Tatiana
I don't see why it would use anything other than just copying the beginning of the URL in .href. DNS doesn't have information about URLs.Catchment
Hmmm its really strange, its not causing me an issue as I can work around it, just curious.Tatiana
Could you be running in compatibility mode in the test environment? Older versions of IE don't have origin.Catchment
window.location.origin was first added in IE11.Catchment
Is this on Windows 10, as I have an issue with window.location.origin not working correctly on a site in IE 11 on Windows 10 (which is a different version to IE 11 on Win 7/8: 11.0.10240.16384 vs 11.0.9600.17842)Bayou
This is on Windows 7. Something else that may contribute to it is that I'm using a network where only port 80 and 443 are open to the internal environment where the test site is hosted. Could this contribute to it? I would have just thought that ie would obtain the value using substrings of the url.Tatiana
Are you still facing this issue? Could this bug be related to it? connect.microsoft.com/IE/feedback/details/1763802/…Christeenchristel
P
7

Intranet sites are set to Compatibility View, which disables window.location.origin:

Pages will run in Compatibility View unless they explicitly specify another document mode. This option can be disabled using the Tools > Compatibility View Settings menu.

Sites are placed in the Intranet Zone based on the following criteria:

Direct Mapping. As with other Zones, users or network admins may map a list of URL patterns into the Local Intranet Zone. This list is viewable by clicking Tools > Internet Options > Security > Local Intranet > Sites > Advanced.

The PlainHostName rule (aka “The Dot rule”). If the URI’s hostname doesn’t contain any periods (e.g. http://team/) then it is mapped to the Local Intranet Zone.

The fixed Proxy Bypass list. If the user has a fixed proxy specified inside Tools > Internet Options > Connections > LAN Settings, then sites listed to bypass that proxy will be mapped to the Local Intranet zone. The fixed proxy bypass list can be found by clicking the Advanced button; it’s at the bottom of the screen in the box labeled Exceptions.

(WPAD) Proxy Script. If the user’s proxy configuration is “Automatically detect settings” or “Use automatic configuration script” inside Tools > Internet Options > Connections > LAN Settings, the browser will run the FindProxyForUrl function in the specified WPAD proxy configuration script to determine which proxy should be used for each request. If the script returns “DIRECT”, the browser will bypass the proxy and the site will be mapped into the Local Intranet Zone. When mapping a URL to a Zone, URLMon will call the FindProxyForUrl function to determine if the bypass rule applies. One interesting twist is that the proxy script may itself call dnsResolve to get a site’s IP address and use that information as a part of its determination.

Full-sized flowchart detailing how document modes are chosen in IE11

References

Poe answered 13/8, 2016 at 7:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.