0

What I want is do this:

var siteBaseUrl = window.location.origin;

But in IE 9 it's returning undefined

Trying to understand how do I use modernizr from the suggestion here:

$window.location.origin gives wrong value when using IE

enter image description here

I updated my code to add this block before my siteurl:

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

var siteBaseUrl = window.location.origin;

So now the above works, but I am not sure if modernizr suggestion in the link above can help me do it differently.

Or may be I am confusing myself and the above code is working due to modernizr.

Community
  • 1
  • 1
gbs
  • 7,196
  • 5
  • 43
  • 69

1 Answers1

1

All modernizr will do in this case is tell you that the method is missing. Since it does not fix/polyfill anything itself, you would have to do the same work.

There would be no difference.

Patrick
  • 13,872
  • 5
  • 35
  • 53
  • So just trying to understand - in the code above what is the benefit of adding modernizr. The code will work without modernizer as well correct? – gbs Apr 20 '15 at 18:31
  • The closest thing to a benefit would be if you already check a bunch of global status on the Modernizr object (e.g. `Modernizr.geolocation`, `Modernizr.fontface` etc.) Just for consistency. There is not much of a benefit at all – Patrick Apr 21 '15 at 01:44