天天看點

Location port 屬性

Location port 屬性

Location 對象

port 屬性是一個可讀可寫的字元串,可設定或傳回目前 URL 的端口部分。

<b>注意:</b>如果端口号就是80(這是預設的端口号),無需指定。

location.port

Location port 屬性
Location port 屬性
Location port 屬性
Location port 屬性
Location port 屬性

所有主要浏覽器都支援 port 屬性

傳回目前URL的端口号:

&lt;script&gt;

document.write(location.port);

&lt;/script&gt;

以上執行個體輸出結果:

Location port 屬性