小码哥的IT人生

HTML DOM acceptCharset 属性

JavaScript基础 2022-06-08 15:51:25小码哥的IT人生shichen

HTML DOM acceptCharset 属性

定义和用法

acceptCharset 属性可设置或返回一个逗号分隔的列表,内容是服务器可接受的字符集。

语法

formObject.acceptCharset=charset

实例

下面的例子提示出表单数据可能的字符集:

<html>
<head>
<script type="text/javascript">
function showCharset()
  {
  var x=document.getElementById("myForm")
  alert(x.acceptCharset)
  }
</script>
</head>
<body>
<form id="myForm" acceptCharset="ISO-8859-1">
Text: <input type="text" value="Hello World!">
<input type="button" onclick="showCharset()"
value="Show charset">
</form>
</body>
</html>

TIY

完整实例【取得表单数据可能的字符集】:

<html>
<head>
<script type="text/javascript">
function showCharset()
{
var x=document.getElementById("myForm")
alert(x.acceptCharset)
}
</script>
</head>
<body>
<form id="myForm" acceptCharset="ISO-8859-1">
Text: <input type="text" value="Hello World!">
<input type="button" onclick="showCharset()" value="Show charset">
</form>
</body>
</html>

可以使用本站在线JavaScript测试工具测试上述代码运行效果:http://www.phpcodeweb.com/runjs.html

版权所有 © 小码哥的IT人生
Copyright © phpcodeweb All Rights Reserved
ICP备案号:苏ICP备17019232号-2  

苏公网安备 32030202000762号

© 2021-2024