Timeline for Get protocol, domain, and port from URL
Current License: CC BY-SA 4.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 6, 2022 at 11:10 | comment | added | MEMark |
@bene-we If you mean window.location.origin then you are correct! developer.mozilla.org/en-US/docs/Web/API/Location/origin
|
|
Mar 29, 2022 at 18:37 | comment | added | e-info128 | Works only from a web browser but node or others ES interfaces does not work. | |
Dec 7, 2021 at 10:35 | comment | added | Ali Yar Khan | location is not defined ... | |
Sep 10, 2021 at 15:30 | comment | added | bene-we |
What about window.origin ? Looks exactly like the output asked for ...
|
|
Jul 9, 2021 at 23:31 | history | edited | Kirill Kulakov | CC BY-SA 4.0 |
location.host instead of location.hostname + location.port
|
Aug 30, 2019 at 11:25 | comment | added | Anders Lindén |
Upvoting for hinting that location.protocol contains the colon.
|
|
May 14, 2018 at 23:25 | review | Suggested edits | |||
May 15, 2018 at 4:28 | |||||
Sep 20, 2016 at 14:28 | comment | added | c24w |
Can't you use location.host instead of location.hostname + location.port ?
|
|
Oct 7, 2015 at 16:37 | comment | added | Shef | Sorry for the late reply, @NickT. Yes, it does't do that. Please, use the nice solution provided by David for that. | |
Oct 5, 2015 at 22:57 | comment | added | Nick T |
This doesn't work at all if you have a URL string, right? (i.e. you need to be at location for this to work)
|
|
Sep 2, 2012 at 6:27 | comment | added | Shef |
@Randomblue What about it? You will get about:// . However, I am curious to know, what would be the use case for about:blank ? I am not sure if any browser injects plugin resources in about:blank , but seems like that could be the only use case.
|
|
Aug 4, 2011 at 12:45 | history | answered | Shef | CC BY-SA 3.0 |