A fix for window.location.origin in Internet Explorer

A straightforward fix for this issue 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

Productivity

5 ways to speed up your software development

I love feeling like I am speeding through development tasks, here are five things that can help speed up your software development

Accessibility SEO

The main reasons why we shouldn't use click here as link text

There are many reasons why we shouldn't use click here or similar as link text, let's go through them