A fix for window.location.origin in Internet Explorer

Internet Explorer does not have access to window.location.origin, which is a bummer because it is a pretty handy variable to have, but we can make it work with a fairly straight forward check because we access .origin;

if (!window.location.origin) {
  window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
}

This should now have .origin set to what you would expect.

Recent posts View all

Slack

Adding an integration to a Slack room

How to add an integration to a Slack room. Part of our Slack mini series.

Simple CS

Abstract Syntax Trees

Let's learn about Abstract Syntax Trees, what they are and why we need them.