Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • This was already answered long ago. And this answer is wrong regarding the question as it will still provide https:// as the origin protocol if the page is https - but it should strip the protocol/readd it as http. Commented Jan 22, 2015 at 11:21
  • Isn't there the host name missing in the for-IE code? Like window.location.origin = window.location.protocol + "//" + (window.location.port ? ':' + window.location.port : '') + '/' + window.location.hostname; Commented Jan 18, 2016 at 15:03
  • yes, but not in that order : window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : ''); Commented Mar 16, 2017 at 14:17