Table#
For example url https://example.org:8080/path/?arg=a&arg2=b#toc
:
Property | Value | Blankable |
---|---|---|
href | https://example.org:8080/path/?arg=a&arg2=b#toc | |
origin | https://example.org | |
protocol | https: | |
hostname | example.org | |
host | example.org:8080 | only "example.org" when using default port |
port | 8080 | empty "" when using default port |
pathname | /path/ | at least the root path "/" |
search | ?arg=a&arg2=b | empty "" when no arguments (event write the question sign "?" ) |
hash | #toc | empty "" when no toc (even write the hash sign "#" ) |
References#
- 《[JS] Javascript 取得目前 URL 與相關參數(總整理)》https://seanacnet.com/js/location/
- 《javascript - location.host vs location.hostname and cross-browser compatibility? - Stack Overflow》https://stackoverflow.com/questions/6725890/location-host-vs-location-hostname-and-cross-browser-compatibility