https://github.com/shinnn/location-origin.js
Polyfill for window.location.origin
https://github.com/shinnn/location-origin.js
Last synced: 19 days ago
JSON representation
Polyfill for window.location.origin
- Host: GitHub
- URL: https://github.com/shinnn/location-origin.js
- Owner: shinnn
- License: mit
- Created: 2014-03-30T13:53:51.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-18T14:33:00.000Z (over 10 years ago)
- Last Synced: 2025-06-11T00:48:43.504Z (about 1 month ago)
- Language: JavaScript
- Size: 469 KB
- Stars: 14
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
# location-origin.js
[](https://github.com/shinnn/location-origin.js/releases)
[](https://www.npmjs.com/package/location-origin)
[](https://travis-ci.org/shinnn/location-origin.js)
[](https://david-dm.org/shinnn/location-origin.js#info=devDependencies)[](https://ci.testling.com/shinnn/location-origin.js)
Polyfill for [`window.location.origin`](https://url.spec.whatwg.org/#dom-urlutilsreadonly-origin)
```javascript
// On http://localhost:8888/path/to/page.html#hash?search=foobarwindow.location.origin; //=> "http://localhost:8888"
```## Installation
### Package managers
#### [Bower](http://bower.io/)
```sh
bower install location-origin
```#### [npm](https://www.npmjs.com/)
```sh
npm install location-origin
```#### [Duo](http://duojs.org/)
```javascript
// You don't have to assign it to a variable.
// It automatically adds `origin` property to the window.location object when it is `require`d.
require("shinnn/location-origin.js");
```### Standalone
[Download the script file directly.](https://raw.githubusercontent.com/shinnn/location-origin.js/master/dist/location-origin.js "view raw")
## Acknowledgements
I used [the blog post by Toby Osbourn](http://tosbourn.com/2013/08/javascript/a-fix-for-window-location-origin-in-internet-explorer/ "A fix for window.location.origin in Internet Explorer") as reference.
Thanks, [tosbourn](https://github.com/tosbourn).## License
[src/location-origin.coffee](./src/location-origin.coffee) and [dist/location-origin.js](./dist/location-origin.js) are licensed under [the Unlicense](./LICENSE-UNLICENSE).
All other source code is licensed under [the MIT license](./LICENSE-MIT).