Anchor charsetProperty
Anchor Object
Definition and Usage
The charset property sets or returns the value of the charset attribute of a link.
The charset attribute specifies the character set of the linked resource.
Syntax
Set the charset property:
anchorObject.charset="charset"
Return the charset property:
anchorObject.charset
| Value | Description |
|---|---|
| charset | Specifies the character set of the linked resource |
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the charset property
Example
Example
Return the charset attribute value of the link:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
</head>
<body>
<a id="example" charset="ISO-8859-1" href="//www.example.com/">Example</a><br>
<script>document.write("Return the charset of the link: ");
document.write(document.getElementById('example').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("Set the charset of the link: ");
document.write(document.getElementById('google').charset);</script>
</body>
</html>
Try it Yourself »
Anchor Object Other Extensions