小白教程
所有教程
关于
Search
172.70.100.59
172.70.100.59
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Prop document doctype”的源代码
本页内容
上一节:
Met_document_createtextnode
下一节:
Prop_document_documentelement
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:document.doctype}}[[Category:dom obj document|14]] = HTML DOM doctype 属性 = [[dom obj document|Document 对象]] 返回 HTML 文档的文档类型对象: <sample title="" desc="" lang="html" hererun="1"> document.doctype; </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> </head> <body> <p id="demo">单击按钮来显示文档类型名称。</p> <button onclick="myFunction()">点我</button> <script> function myFunction(){ var x=document.getElementById("demo"); x.innerHTML=document.doctype.name; } </script> <p><strong>注意:</strong>在IE 8和更早的版本,对于HTML和XHTML文档doctype属性返回<em>null</em> ,只在XML文档下工作。</p> </body> </html> </run> == 定义和用法 == doctype 属性可返回与文档相关的文档类型声明(Document Type Declaration)。 阅读更多文档类型对象的知识,请查看 [[dom obj documenttype|文档类型对象参考手册]]. '''注意:''' 如果文档没有指定文档类型,返回值为 null. == 浏览器支持 == 所有主要浏览器都支持 doctype 属性 '''注意:''' Internet Explorer 8 及 IE 更早版本显示HTML 和 XHTML文档时该属性返回 null ,但是支持 XML 文档. == 语法 == <pre> document.doctype</pre> == 技术细节 == {| class="table table-striped table-hover" | 返回值: | 文档的文档类型, 作为一个 DocumentType 对象。 |- | DOM 版本 | Core Level 1 Document 对象 |} [[dom obj document|Document 对象]]
返回至“
Prop document doctype
”。
上一节:
Met_document_createtextnode
下一节:
Prop_document_documentelement