jQuery IE10 (9,8) 无法识别 DOCTYPE xhtml

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15221265/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 14:37:19  来源:igfitidea点击:

IE10 (9,8) does not recognize DOCTYPE xhtml

jqueryinternet-explorermootoolsdoctype

提问by Peminator

IE10 rejects to launch some jQuery code, as far I found on runtime somewhere a doctype is wrong detected and prepended with 4.01 transitional version

IE10 拒绝启动一些 jQuery 代码,据我所知,我在运行时发现某个文档类型错误,并以 4.01 过渡版本为前缀

in IE's developer tools viewing the console i see HTML1524: Invalid DOCTYPE. The shortest valid doctype is "<!DOCTYPE html>". and following (runtime modified) html:

在 IE 的开发人员工具中查看控制台我看到了 HTML1524: Invalid DOCTYPE. The shortest valid doctype is "<!DOCTYPE html>"。和以下(运行时修改)html:

I believe both misuse of DOCTYPE and some jQuery not working have a common reason, but did not find what it is

我相信误用 DOCTYPE 和一些 jQuery 不工作都有一个共同的原因,但没有找到它是什么

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!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" slick-uniqueid="1"><HEAD><META 
content="IE=10.000" http-equiv="X-UA-Compatible">

<META http-equiv="X-UA-Compatible" content="IE=edge">
<META http-equiv="Content-Type" content="text/html; charset=windows-1250">
<TITLE>....

while IE states to run in standards mode, still some things do not work(mainly replacing the links with jQuery's on click events to show content instead loading whole new page - used for unpacking other menu branch using accordion, original links in category headers with href are fallback only for case jQuery fails to animate accordion)

虽然IE 声明在标准模式下运行,但仍然有些事情不起作用(主要是用 jQuery 的点击事件替换链接以显示内容而不是加载整个新页面 - 用于使用手风琴解压缩其他菜单分支,类别标题中的原始链接与 href仅在 jQuery 无法为手风琴设置动画的情况下回退)

too many other on click events or jquery ui functions to make link to look like button fail to function in IE while working in other browsers

太多其他点击事件或 jquery ui 函数使链接看起来像按钮在其他浏览器中工作时无法在 IE 中运行

original html as provided from server is following:

服务器提供的原始 html 如下:

<!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" xml:lang="sk" lang="sk">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250" />
<title>...

i am forced to use both mootools and jQuery and know the slick-uniqueid in htm atributes is from moo, don know if it may be the same who edits the doctype, but Im sure it happens in IE browsers only, Chrome and Firefox just work ok

我被迫同时使用 mootools 和 jQuery,并且知道 htm 属性中的 slick-uniqueid 来自 moo,不知道编辑文档类型的人是否相同,但我确定它只发生在 IE 浏览器中,Chrome 和 Firefox 可以正常工作好的

jQuery scripts are loaded from external js file, wrapped in jQuery(function() {..and all use full variable name jQuery instead of dollarsign, for example jQuery("#myid").click( function(e){...

jQuery 脚本从外部 js 文件加载,包裹在jQuery(function() {..并且都使用完整的变量名 jQuery 而不是美元符号,例如jQuery("#myid").click( function(e){...

as using both mootools and jQuery (I know i should not but need some mootools plugin for slideshow with thumbnails and KenBurns effect /anyone knows free jQ alternative??/) and jQuery is loaded firstand within scripts i use only jQuery()... so the $ dollarsign is all free for mootoolsto use later on as it is loaded just if needed, withing the body (not sure thats ok but thats the way how 'visualslideshow' presented it)

因为同时使用 mootools 和 jQuery(我知道我不应该但需要一些带有缩略图和 KenBurns 效果的幻灯片的 mootools 插件/任何人都知道免费的 jQ 替代方案??/)并且首先加载 jQuery,并且在脚本中我只使用jQuery().. . 所以 $ 美元符号是免费供 mootools稍后使用的,因为它只是在需要时加载,与身体一起(不确定那是否可以,但这就是 'visualslideshow' 呈现它的方式)

I'd be glad to hear any ideas or suggestions on how to identify or fix it to get the jQuery working right (v1.8)

我很高兴听到有关如何识别或修复它以使 jQuery 正常工作的任何想法或建议(v1.8)

回答by userx

Change your DOCTYPE to:

将您的 DOCTYPE 更改为:

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

(using XHTML strict instead of transitional)

(使用 XHTML 严格而不是过渡)

IE10 will stop throwing the error in the console. I'm not sure why IE10 doesn't like transitional XHTML any more. If anyone has a way for IE10 to recognize the XHTML 1.0 Transitional DOCTYPE, that would be awesome.

IE10 将停止在控制台中抛出错误。我不知道为什么 IE10 不再喜欢过渡 XHTML。如果有人有办法让 IE10 识别 XHTML 1.0 Transitional DOCTYPE,那就太棒了。

回答by james31rock

I was able to get rid of the error by using

我能够通过使用摆脱错误

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

instead of

代替

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

回答by Invincible

I had same issue. It worth looking at any external libraries you are using. I was using BXSlider and it wasn't happy with jQuery 1.8 on IE10. Due to which IE10 was failing and showing message.

我有同样的问题。值得查看您正在使用的任何外部库。我正在使用 BXSlider,它对 IE10 上的 jQuery 1.8 不满意。由于 IE10 失败并显示消息。

  HTML1524: Invalid DOCTYPE. The shortest valid doctype is "<!DOCTYPE html>

My solution was to upgrade my JQuery to 1.9.1 and also include jQuery migrate.

我的解决方案是将我的 JQuery 升级到 1.9.1 并且还包括 jQuery migrate。

      <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
      <script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>

Hope this helps someone.

希望这可以帮助某人。

回答by user2584478

This happens to me in IE and FireFox, because when i included the css i wrote "< link rel="stylesheet" type="text/javascript ..."

这在 IE 和 FireFox 中发生在我身上,因为当我包含我写的 css 时 "< link rel="stylesheet" type="text/javascript ..."

i just change it to type="text/css"and it works.

我只是将其更改为type="text/css"并且它有效。

回答by Ast Derek

You have a typo in your secondfirst DOCTYPEdefinition, the W3C is missing ahas an extra c:

您的第二个第一个DOCTYPE定义中有一个错字,W3C缺少一个额外的c

                                                                             v-- extra "c"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Try fixing that and test again.

尝试修复并再次测试。