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

<h1>window.location 对象</h1>

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

<script>
document.getElementById("demo").innerHTML =
"页面协议是:" + window.location.protocol;
</script>

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