HTML DOM enctype 属性
定义和用法
enctype 属性可设置或返回用于编码表单内容的 MIME 类型。
如果表单没有 enctype 属性,那么当提交文本时的默认值是 "application/x-www-form-urlencoded"。
当 input type 是 "file" 时,值是 "multipart/form-data"。
语法
- formObject.encoding=encoding
实例
下面的例子可返回表单的编码类型:
- <html>
- <head>
- <script type="text/javascript">
- function showEnctype()
- {
- var x=document.getElementById("myForm")
- alert(
x.enctype
)- }
- </script>
- </head>
- <body>
- <form id="myForm" enctype="application/x-www-form-urlencoded">
- Name: <input type="text" value="Mickey Mouse" />
- <input type="button" onclick="showEnctype()"
- value="Show enctype" />
- </form>
- </body>
- </html>