ใช้วัตถุ window.location เพื่อส่งคืนโปรโตคอล หน้าต่าง .ล ocation.protoco l จะส่งคืนโปรโตคอลของเว็บเช่น http หรือ https −
ตัวอย่าง
<!DOCTYPE html>
<html>
<body>
<script>
document.write("https or https: <br>The protocol is:"+window.location.protocol);
</script>
</body>
</html>