Location port 屬性

定義和用法
port 屬性是一個可讀可寫的字符串,可設置或返回當前 URL 的端口部分。
注意:如果端口號就是80(這是默認的端口號),無需指定。
語法
location.port
瀏覽器支持
所有主要瀏覽器都支持 port 屬性
實例
實例
返回當前URL的端口號:
<script>
document.write(location.port);
</script>
document.write(location.port);
</script>
以上實例輸出結果:
document.write(location.port);
嘗試一下 ?

更多建議: