Link charsetProperty
Link Object
Definition and Usage
The charset property sets or returns the character encoding of the linked document.
Syntax
Setting the charset property:
linkObject.charset="character-set"
Returning the charset property:
linkObject.charset
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the charset property
Example
Example
Display the character encoding of the linked document:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial(example.com)</title>
<link id="link1" href="domoarigato.htm.html" charset="ISO-2022-JP">
<script>
function displayResult(){
var x=document.getElementById("link1").charset;
alert(x);
}
</script>
</head>
<body>
<button type="button" onclick="displayResult()">Display the character set of the link element</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial(example.com)</title>
<link id="link1" href="domoarigato.htm.html" charset="ISO-2022-JP">
<script>
function displayResult(){
var x=document.getElementById("link1").charset;
alert(x);
}
</script>
</head>
<body>
<button type="button" onclick="displayResult()">Display the character set of the link element</button>
</body>
</html>
Try it Yourself »
Link Object Other Extensions