HTML DOM Anchor charset 属性

Anchor charset 属性

Anchor 对象参考手册 Anchor对象

定义和用法

charset 可设置或返回链接的 charset 属性值。

charset 属性指定了被链接资源的字符集。

语法

设置 charset 属性:

anchorObject.charset="charset"

返回 charset 属性:

anchorObject.charset
描述
charset指定被链接资源的字符集

浏览器支持

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

实例

实例

返回链接的 charset 属性值:


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>知识兔(zhishitu.com)</title>
</head>
<body>
 
<a id="zhishitu" charset="ISO-8859-1" href="//www.zhishitu.com/">知识兔</a><br>
<script>
document.write("返回链接的charset: ");
document.write(document.getElementById('zhishitu').charset);
document.write("<br><br>");
</script>
<a id="google" href="//www.google.com/">Google</a><br>
<script>
document.getElementById('google').charset="utf-8";
document.write("设置链接的charset: ");
document.write(document.getElementById('google').charset);
</script>
 
</body>
</html>

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