HTML DOM port 屬性
定義和用法
port 屬性是一個(gè)可讀可寫(xiě)的字符串,可設(shè)置或返回當(dāng)前 URL 的端口部分。
語(yǔ)法
location.port=portnumber
實(shí)例
假設(shè)當(dāng)前的 URL 是: http://example.com:1234/test.htm#part2:
<html> <body> <script type="text/javascript"> document.write(location.port); </script> </body> </html>
輸出:
1234