HTML DOM Area host 属性

2018-08-04 20:39 更新

Area host 属性

Area 对象参考手册 Area 对象

定义和用法

host 属性克设置或者返回 href 属性值的 主机名:端口 部分。

语法

areaObject.host=hostname:port


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持 host 属性


提示和注释

注意: 如果在URL中端口部分没有指定,或者端口为80(默认值),一些浏览器将不会显示端口部分。


实例

实例

下面的例子可返回 "Venus" 区域的主机名和端口:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool教程(w3cschool.cn)</title>
</head>
<body>

<img src="planets.gif" width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
<p>金星区域的 hostname:port:
<script>
document.write(document.getElementById('venus').host);
</script>
</p>
<p><b>注意:</b>如果没有指定端口部分的URL,或者是80(默认),一些浏览器将不会显示端口的部分。</p>

</body>
</html>

以上实例输出结果:

金星区域的 hostname:port: www.w3cschool.cn

尝试一下 »


Area 对象参考手册 Area 对象
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号