Baseline Widely available *
Location
ã¤ã³ã¿ã¼ãã§ã¤ã¹ã¯ãé¢é£ä»ãããããªãã¸ã§ã¯ãã®å ´æ (URL) ã表ãã¾ãã夿´ãè¡ãããã¨ãé¢é£ãããªãã¸ã§ã¯ãã«åæ ããã¾ãã Document
ããã³ Window
ã¤ã³ã¿ã¼ãã§ã¤ã¹ã«ã¯ãã®ãããªé¢é£ä»ãããã Location
ãããããããã Document.location
ããã³ Window.location
ã§ã¢ã¯ã»ã¹ã§ãã¾ãã
ä¸è¨ URL ã®åé¨åã«ãã¤ã³ã¿ã¼ãå½ã¦ãã¨ããã®æå³ã強調ããã¾ãã
<span id="href" title="href"
><span id="origin" title="origin"
><span id="protocol" title="protocol">https:</span>//<span
id="host"
title="host"
><span id="hostname" title="hostname">example.org</span>:<span
id="port"
title="port"
>8080</span
></span
></span
><span id="pathname" title="pathname">/foo/bar</span
><span id="search" title="search">?q=baz</span
><span id="hash" title="hash">#bang</span></span
>
html {
display: table;
width: 100%;
}
body {
display: table-cell;
text-align: center;
vertical-align: middle;
font-family: Georgia;
font-size: 175%;
line-height: 1em;
white-space: nowrap;
}
[title] {
position: relative;
display: inline-block;
box-sizing: border-box;
line-height: 2em;
cursor: pointer;
color: gray;
}
[title]::before {
content: attr(title);
font-family: monospace;
position: absolute;
top: 100%;
width: 100%;
left: 50%;
margin-left: -50%;
font-size: 60%;
line-height: 1.5;
background: black;
}
[title]:hover::before,
:target::before {
background: black;
color: yellow;
}
[title] [title]::before {
margin-top: 1.5em;
}
[title] [title] [title]::before {
margin-top: 3em;
}
[title] [title] [title] [title]::before {
margin-top: 4.5em;
}
[title]:hover,
:target {
position: relative;
z-index: 1;
outline: 50em solid rgba(255, 255, 255, 0.8);
}
document.body.addEventListener("click", (event) => {
event.preventDefault();
window.location.hash = event.target.hasAttribute("id")
? `#${event.target.getAttribute("id")}`
: "";
});
ã¤ã³ã¹ã¿ã³ã¹ããããã£
Location.ancestorOrigins
éç㪠DOMStringList
ã§ãæå®ããã Location
ãªãã¸ã§ã¯ãã«é¢é£ä»ããããææ¸ã®ããã¹ã¦ã®ç¥å
ã®é²è¦§ã³ã³ããã¹ããéé ã«ä¿æãã¾ãã
Location.href
URL å ¨ä½ãåããæååãè¿ãæåååã§ãããã®å¤ã夿´ããã¨ãé¢é£ä»ããããææ¸ãæ°ãããã¼ã¸ã¸ç§»åãã¾ãããã®å¤ã¯ãé¢é£ä»ããããææ¸ã®ãã®ã¨ã¯ç°ãªããªãªã¸ã³ããè¨å®ã§ãã¾ãã
Location.protocol
æ«å°¾ã® ':'
ãå«ããURL ã®ãããã³ã«ã¹ãã¼ã ãåããæååã§ãã
Location.host
URL ã®ãã¹ã (ããªãã¡ãã¹ãåã':'
ããã¼ãçªå·) ãåããæååã§ãã
Location.hostname
URL ã®ãã¡ã¤ã³ãåããæååã§ãã
Location.port
URL ã®ãã¼ãçªå·ãåããæååã§ãã
Location.pathname
URL ã®ãã¹é¨åã§ãå
é ã® '/'
ã«ç¶ã㦠URL ã®ãã¹é¨åãå
¥ã£ããã®ã§ãã¯ã¨ãªã¼æååããã©ã°ã¡ã³ããå«ããªãæååã§ãã
Location.search
URL ã®ãã¡ã '?'
ã¨ããã«ç¶ã弿°ããã¯ã¨ãªã¼æååããåããæååã§ããæè¿ã®ãã©ã¦ã¶ã¼ã¯ãã¯ã¨ãªã¼æååãã弿°ã容æã«è§£æããããã® URLSearchParams ã URL.searchParams ãæä¾ãã¦ãã¾ãã
Location.hash
URL ã®ãã¡ã '#'
ã¨ããã«ç¶ããã©ã°ã¡ã³ãèå¥åãåããæååã§ãã
Location.origin
èªåå°ç¨
ç¹å®ã®ä½ç½®ã®ãªãªã¸ã³ã®æ£è¦å½¢ãåããæååã§ãã
Location.assign()
弿°ã§æå®ãã URL ã®ãªã½ã¼ã¹ãèªã¿è¾¼ã¿ã¾ãã
Location.reload()
ç¾å¨ã® URL ã®ãªã½ã¼ã¹ãåèªã¿è¾¼ã¿ãã¾ãã
Location.replace()
ç¾å¨ã®ãªã½ã¼ã¹ããæå®ãã URL ã®ãªã½ã¼ã¹ã§ç½®ãæãã¾ãã assign()
ã¡ã½ããã¨ã®éãã¯ãreplace()
ã使ç¨ããå¾ã¯ç¾å¨ã®ãã¼ã¸ãã»ãã·ã§ã³ã® History
ã«ä¿åãããªããã¨ã§ãããã¦ã¼ã¶ã¼ã¯æ»ããã¿ã³ã使ç¨ãã¦ç§»åãããã¨ãã§ãã¾ããã
Location.toString()
URL å
¨ä½ãåããæååãè¿ãã¾ãããã㯠Location.href
ã¨å義ã§ããããã¡ãã¯å¤ã夿´ããããã«ä½¿ç¨ã§ãã¾ããã
// location: https://developer.mozilla.org:8080/en-US/search?q=URL#search-results-close-container
const loc = document.location;
console.log(loc.href); // https://developer.mozilla.org:8080/en-US/search?q=URL#search-results-close-container
console.log(loc.protocol); // https:
console.log(loc.host); // developer.mozilla.org:8080
console.log(loc.hostname); // developer.mozilla.org
console.log(loc.port); // 8080
console.log(loc.pathname); // /en-US/search
console.log(loc.search); // ?q=URL
console.log(loc.hash); // #search-results-close-container
console.log(loc.origin); // https://developer.mozilla.org:8080
location.assign("http://another.site"); // load another page
仿§æ¸ ãã©ã¦ã¶ã¼ã®äºææ§ é¢é£æ
å ±
Location
ã®ããããã£: Window.location
ããã³ Document.location
.URL
, URLSearchParams
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4