我想知道和理解,有可能改变文档类型吗?我在谷歌上浏览了很多,但并没有弄清楚这一点。
我的工作是基于CMS的布局,在那里我没有多余的html代码。我只需修改CSS并添加脚本来添加div和其他html元素。
我们在html编码中使用旧的doctype。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
因此,我无法处理最新的html5文档类型。我想在那里问id,我可以将旧的doctype更新为html5 doctype吗?
需要帮助。
谢谢,
发布于 2016-03-16 23:24:51
https://developer.mozilla.org/en/document.doctype
doctype是只读属性。
不幸的是,您无法修改doctype。
编辑:实际上你可以。真奇怪。
var doctype = document.implementation.createDocumentType(
'html',
'',
''
);
document.doctype.parentNode.replaceChild(doctype, document.doctype);
告诉我这对你来说是怎么回事。
https://stackoverflow.com/questions/36053988
复制