如何修改DNN默认的DOCTYPE

简介: DNN 默认的DOCTYPE在IE 6.0下会触发IE进入quirks模式(会有什么影响),那如何修改DNN的DOCTYPE呢?Cathal Connolly 给出了一个解决方案 原文: Whilst the 4.
DNN 默认的DOCTYPE在IE 6.0下会触发IE进入quirks模式( 会有什么影响),那如何修改DNN的DOCTYPE呢? Cathal Connolly 给出了一个解决方案

原文:
Whilst the 4.4 release predominantly focussed on performance and optimisation, there were a number of other enhancements added to the release (as always the changelog is the best place to view changes). One of these, that should be of interest to skinners and those interested in accessibility standards & xhtml compliance, is support for skin level doctypes .

Historically, if you wanted to target your skin/container for a particular version of html/xhtml, you had to manually edit the default.aspx page to alter the hardcoded DOCTYPE declaration. With 4.4, the declaration has been made dynamic, to allow users to declare particular doctypes with particular skins. To make use of this, you create a file with the same name as your skin except ending in doctype.xml (rather than ascx/htm/html) and it’ll be picked up during skin load. This xml file should contain a single node,SkinDocType, that contains a declaration of your desired doctype. To ensure that the parser reads the value correctly, you need to use a CDATA section to escape out the various < and & characters e.g. If I have a skin called mypage.asx that I intended to render as XHTML 1.0 strict, then I would create a file called mypage.doctype.xml which would  contain the following:

<SkinDocType><![CDATA[<!DOCTYPE XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">]]></SkinDocType>


对此 John Mitchell认为这个解决方案不灵活,每次页面加载的XML解析会降低效率,他提出的解决方案如下:

原文:
Brand new in DNN 4.4 is the option to change your Doctype  which Cathal blogged about.

As Cathal pointed out in this thread the implementation will need to be improved for performance because on every request the DNN framework is looking for an XML file and loading it into an XML Document to validate the XML.

There is also concern that it is hard to implement with multiple skins because you would need a different XML file for every Skin.

You can shortcut all of this now and not take the performance hit by using the code below.

Just copy and paste the following code directly into your HTML or .ASCX skin file.

< script runat = " server " >
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   Dim skinDocType 
as  Control  =  Me.Page.FindControl( " skinDocType " )
   If Not skinDocType 
is  Nothing
      CType(skinDocType, System.Web.UI.WebControls.Literal).Text
= " <!DOCTYPE html PUBLIC  "" -//W3C//DTD XHTML 1.0 Strict//EN ""   "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd "" > "
   End If
End Sub
</ script >

时间有限,就不翻译了,贴出来供大家参考。
相关文章
|
8月前
|
数据可视化 前端开发
HTML基础结构和常用标记的例子
HTML基础结构和常用标记的例子
53 0
|
4月前
|
前端开发 JavaScript
html图像属性的高级用法
在HTML中,通过结合CSS、JavaScript及其他HTML元素,可以实现图像属性的高级用法,例如响应式图像、懒加载、图像映射、CSS滤镜、SVG图像、图像作为背景以及使用JavaScript动态更改图像。
|
5月前
HTML标记 和标记的属性
【8月更文挑战第28天】HTML标记 和标记的属性。
69 1
|
7月前
|
前端开发 JavaScript
HTML 全局属性介绍及示例
HTML 全局属性介绍及示例
|
7月前
|
数据采集 移动开发 搜索推荐
HTML基础-HTML5新增语义标签:解锁网页结构新维度
【6月更文挑战第5天】本文介绍了HTML5的语义标签,旨在提升网页结构化和可访问性。核心语义标签包括`&lt;header&gt;`、`&lt;nav&gt;`、`&lt;main&gt;`、`&lt;article&gt;`、`&lt;section&gt;`、`&lt;aside&gt;`、`&lt;footer&gt;`、`&lt;figure&gt;`和`&lt;figcaption&gt;`。常见问题包括滥用标签作布局工具、忽略`&lt;main&gt;`、不恰当嵌套和忽视辅助功能。
145 3
|
8月前
|
前端开发 JavaScript
HTML深度解析:更改文本颜色
【4月更文挑战第1天】
191 0
HTML深度解析:更改文本颜色
|
图形学
模型粗糙度怎么修改?
模型粗糙度属性可以用于各种需要模拟不同材质表面光滑度和纹理的场景。
99 0
|
PHP
PHP - Laravel 未转义输出,输出 HTML 标签到页面展示({!! $变量 !!})
PHP - Laravel 未转义输出,输出 HTML 标签到页面展示({!! $变量 !!})
166 0
|
数据采集 移动开发 前端开发
HTML——结构与简单标签基础
HTML——结构与简单标签基础
117 0
HTML——结构与简单标签基础
|
移动开发 JavaScript HTML5
HTML5 - 数据集属性
HTML5定义了关于操作标准自定义属性的用法,以下是一个示例: 元素属性
962 0

热门文章

最新文章