如何与QUOT;启用"在IE 8通过AJAX调用中插入HTML5元素?

问题描述:

查看解决方案的问题的底部。

IE 8(或更低)不工作良好,未知的元素(即HTML5元素),一个不能他们的风格,或访问他们的大部分道具。他们有许多变通此例如: http://remysharp.com/ 2009年/ 01/07 / HTML5启用脚本/

IE 8 (and lower) does not work good with unknown elements (ie. HTML5 elements), one cannot style them , or access most of their props. Their are numerous work arounds for this for example: http://remysharp.com/2009/01/07/html5-enabling-script/

现在的问题是,这个伟大工程的静态HTML,这是可在页面加载,但是当一个创建HTML5元素之后(例如AJAX调用包含它们,或者干脆用JS创建),它将标志着这些新加入的元素它们为 HTMLUnknownElement 作为应该 HTMLGenericElement (IE浏览器中的调试器)。

The problem is that this works great for static HTML that was available on page load, but when one creates HTML5 elements afterward (for example AJAX call containing them, or simply creating with JS), it will mark these newly added elements them as HTMLUnknownElement as supposed to HTMLGenericElement (in IE debugger).

有谁知道一个变通的是,让新加入的元素将被识别/启用由IE 8?

Does anybody know a work around for that, so that newly added elements will be recognized/enabled by IE 8?

下面是一个测试页面:

<html><head><title>TIME TEST</title>
    <!--[if IE]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
</head>

<body>
    <time>some time</time>
    <hr>
    <script type="text/javascript">
        $("time").text("WORKS GREAT");
        $("body").append("<time>NEW ELEMENT</time>"); //simulates AJAX callback insertion
        $("time").text("UPDATE");
    </script>
</body>
</html>

在IE中,您将看到:UPDATE和新元素。 在其他任何现代的浏览器,你会看到UPDATE和更新

In IE you will see the: UPDATE , and NEW ELEMENT. In any other modern browser you will see UPDATE, and UPDATE

对于我使用 html5shiv 在IE7的所有HTML5的问题>和适应HTML5元素回来的ajax调用我使用 innershiv

for all html5 issues in IE7 i use html5shiv and to accommodate the html5 elements coming back in ajax calls i use innershiv.

这两个小插件为止工作对我来说就像一个魅力。

these two small plugins worked for me like a charm so far.

- 普利文Gunasekara

-- Praveen Gunasekara