天天看點

如何修改DNN預設的DOCTYPE

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>

http://www.dotnetnuke.com/Community/BlogsDotNetNuke/tabid/825/EntryID/1226/Default.aspx

對此

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.

如何修改DNN預設的DOCTYPE

<script runat="server">

如何修改DNN預設的DOCTYPE

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

如何修改DNN預設的DOCTYPE

   Dim skinDocType as Control = Me.Page.FindControl("skinDocType")

如何修改DNN預設的DOCTYPE

   If Not skinDocType is Nothing

如何修改DNN預設的DOCTYPE

      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"">"

如何修改DNN預設的DOCTYPE

   End If

如何修改DNN預設的DOCTYPE

End Sub

如何修改DNN預設的DOCTYPE

</script>

時間有限,就不翻譯了,貼出來供大家參考。