HTML1527:DOCTYPE的预期。最短的有效DOCTYPE是"<!DOCTYPE HTML>" [英] HTML1527: DOCTYPE expected. The shortest valid doctype is "<!DOCTYPE html>"

查看:4871
本文介绍了HTML1527:DOCTYPE的预期。最短的有效DOCTYPE是"<!DOCTYPE HTML>"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我工作的一个C#的Web应用程序,一切工作正常,直到我在一个正常的JavaScript添加。

I am working on a c# web application, everything is working until I add in a normal JavaScript.

HTML代码的东西如下:

The html code is something as follow:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="scripts/JScript.js" type="text/javascript"></script>
<asp:ContentPlaceHolder id="headContent" runat="server">
    </asp:ContentPlaceHolder>
</head> 
<body>

<asp:ContentPlaceHolder id="title" runat="server"></asp:ContentPlaceHolder>
<asp:ContentPlaceHolder id="bodyContent" runat="server"></asp:ContentPlaceHolder>
<!-- some code here -->
</body>



JScript.js 是JavaScript代码。放在

The JScript.js is the JavaScript that put in.

JavaScript代码的东西如下:

The JavaScript code is something as follow:

function getCookie(catId) {
  var ebRand = Math.random() + '';
ebRand = ebRand * 1000000; 

document.write('<scr' + 'ipt src="HTTP://bs.serving-sys.com/Serving/ActivityServer.bs?cn=as&amp;ActivityID=553971&amp;rnd=' + ebRand + '"></scr' + 'ipt>');
}

这JavaScript函数会触发当链接按钮点击。

This JavaScript function will be trigger when a link button is click.

我打了错误的IE浏览器,但浏览器和Mozilla工作正常。

I hit error in IE but Chrome and Mozilla is working fine.

我在IE浏览器的控制台错误是
HTML1527:DOCTYPE的预期。最短的有效文档类型为<!DOCTYPE HTML>中。

My error in IE console is HTML1527: DOCTYPE expected. The shortest valid doctype is "<!DOCTYPE html>".

在谷歌搜索后,我试图把在

After search in Google, I try to put in

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



新的 DOCTYPE ,但它不工作。另

和我已经尽量把

<meta http-equiv="X-UA-Compatible" content="IE=edge" />



< HEAD>< /头>

但我仍然得到同样的错误在IE浏览器也。

But I still get the same error in IE also.

是在的ContentPlaceHolder

其他重要的是,我已经去W3C验证服务做地址的一些验证:

Other than that, I have go to W3C Markup Validation Service to do some validation of the address :

http://validator.w3.org/check?uri=HTTP%3A%2F%2Fbs.serving-sys.com%2FServing%2FActivityServer.bs%3Fcn% 3Das%26安培%3BActivityID%3D553971%26安培%3Brnd%3D20079.082210606393&安培;字符集=%28detect +自动%29&安培; DOCTYPE =在线&安培;组= 0

并转到 http://validator.w3.org/check 摆在<脚本SRC =HTTP://bs.serving-sys.com/Serving/ActivityServer.bs?cn=as&amp;ActivityID=553971&amp;rnd=20079.082210606393>< / SCRIPT>
为好。

And go to http://validator.w3.org/check to put in <script src="HTTP://bs.serving-sys.com/Serving/ActivityServer.bs?cn=as&amp;ActivityID=553971&amp;rnd=20079.082210606393"></script> as well.

但不明白什么是验证结果的意思。

But not understand what is the validation result means.


请告知我从IE脚本控制台得到什么。

Kindly advise.

推荐答案

IE浏览器发出的警告的约<!DOCTYPE HTML PUBLIC - // W3C // DTD XHTML 1.0过渡// ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> ,因为这样的字符串的不是一个有效的根据HTML5 DOCTYPE。这样的警告,对任何事情没有影响。它只是HTML5布道的一部分

IE issues a warning about <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">, because such a string is not a valid doctype according to HTML5. The warning as such has no impact on anything. It’s just part of HTML5 evangelism.

在将其更改为<!DOCTYPE HTML PUBLIC - // W3C // DTD XHTML 1.0 Strict标准// ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd> ,去除问题。但你可能看到使用一些缓存副本,有一个错误的doctype的结果。用新鲜的文件(使用新名称)测试应该可以解决这个问题。

After you changed it to <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">, the issue was removed. But you probably saw the results of using some cached copy that has a wrong doctype. Testing with a fresh file (with a new name) should fix this issue.

当然,代码本身不验证,因为ASP标签字面上理解和解释为 。内容,但是这是一个不同的问题。

Of course, the code as such does not validate, since the ASP tags are taken literally and interpreted as body content, but that’s a different issue.

实际举动是使用<!DOCTYPE HTML> 的建议。如果您想还是验证对XHTML 1.0规范,例如,可以使用验证器的用户界面,覆盖的doctype做到这一点。

The practical move is to use <!DOCTYPE html> as suggested. If you wish to still validate against the XHTML 1.0 specification for example, you can do this using the validator’s user interface to override the doctype.

但它不是一个大问题;你可以和根本不理会警告。如果你有一些的功能的错误,他们被别的东西造成的,应单独询问,以提供足够的数据。

But it’s not a big issue; you can just as well simply ignore the warning. If you have some functional errors, they are caused by something else and should be asked separately, with sufficient data provided.

这篇关于HTML1527:DOCTYPE的预期。最短的有效DOCTYPE是&QUOT;&LT;!DOCTYPE HTML&GT;&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆