HTML DOM Area hostname 属性

Area hostname 属性

Area 对象参考手册 Area 对象

定义和用法

hostname 属性可设置或返回 href 属性值得主机名部分。

语法

areaObject.hostname=hostname

浏览器支持

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

实例

实例

下面的例子可返回图像映射中 "Venus" 区域的主机名:


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>知识兔(zhishitu.com)</title>
</head>
<body>

<img loading="lazy" src="/planets.gif" width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="Venus" href="https://zhishitu.com/" target="_blank">
</map>
<p>Venus 区域的主机名称:
<script>
document.write(document.getElementById('venus').hostname);
</script>
</p>

</body>
</html>

以上实例输出结果:


Venus 区域的主机名称: www.zhishitu.com

知识兔 »
Area 对象参考手册 Area 对象
计算机