为 XHTML 发送正确的 MIME 类型的ASP代码

Thu, 09 Aug 2007 10:05 AM

前几天到w3c上验证又出新问题,网上查了一下资料,整出一段代码,分享给有需要的朋友。

处理 xhtml 时,要获得最大的兼容性,就需要向 firefox、safari、opera 和其他符合标准的浏览器发送 application/xhtml+xml,而向 IE 发送 text/html:(参考

dim xm
if instr(request.servervariables("http_accept"), "application/xhtml+xml") > 0 or instr(request.servervariables("http_user_agent"), "w3c_validator") > 0 then
response.contenttype="application/xhtml+xml"
xm="<!doctype html public ""-//w3c//dtd xhtml 1.1//en"" ""http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd"">"
else
response.contenttype="text/html"
xm="<!doctype html public ""-//w3c//dtd xhtml 1.0 strict//en"" ""http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"">"
end if

测试:用ie访问查看源代码可以看见输出的是xhtml 1.0 strict。ff或opera下是xhtml1.1

其实不改也可以通过验证的,只不过会有一段警告信息。

i0ne Posted in Design | Comments:0 | Reads:33226

asp:去除HTML代码

Fri, 24 Nov 2006 12:17 AM

<%
'去除HTML代码
function noHTML(str)
dim re
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.Pattern="(\<.[^\<]*\>)"
str=re.replace(str," ")
re.Pattern="(\<\/[^\<]*\>)"
str=re.replace(str," ")
nohtml=str
set re=nothing
end function
%>

i0ne Posted in Web | Comments:0 | Reads:56379

blockquote标签与XHTML验证

Fri, 17 Nov 2006 06:38 PM

今验证首页,发现blockquote必须包含块级元素,不可单用,XHTML 参考没好好看啊

引文区块(Defines an long quotation):
blockquote的内容必须包含块级元素,如标题(h)、段落(p)、列表(ul/ol)和div

i0ne Posted in Design | Comments:1 | Reads:44198

Total:3 Pages:1/1

Other

Css Validator

xhtml1.1 Validator

Creative Commons License

UTF-8