Files

33 lines
943 B
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Local Site — Query</title>
<link rel="stylesheet" href="assets/site.css">
</head>
<body>
<header>
<h1>Query-String Page</h1>
<nav><a href="index.html">Home</a></nav>
</header>
<main>
<p>This page was loaded with a query string. On a file:// URL the query
string is preserved in <code>location.search</code> but should not
affect which file is loaded.</p>
<p>Full URL: <span id="url"></span></p>
<p>Search: <span id="search"></span></p>
<p>Parsed params:</p>
<pre id="params"></pre>
</main>
<script>
var u = new URL(location.href);
document.getElementById('url').textContent = location.href;
document.getElementById('search').textContent = u.search || '(none)';
var params = {};
u.searchParams.forEach(function (v, k) { params[k] = v; });
document.getElementById('params').textContent =
JSON.stringify(params, null, 2);
</script>
</body>
</html>