代码示例:(标识:jsck_location_search)
<!DOCTYPE html>
<html>
<body>

<h1>Window Location 对象</h1>

<h2>search 属性</h2>

<p>
<a id="w3s" href="https://www.sou-xun.com/?answer=yes">
https://www.sou-xun.com/?answer=yes
</a>
</p>

<p id="demo"></p>

<script>
let anchor = document.getElementById("w3s");
let query = anchor.search;

document.getElementById("demo").innerHTML = "URL 的查询部分是:" + query;
</script>

</body>
</html>
运行结果: