解决怪癖模式下的HTML剥离引号? [英] Work around for HTML stripping quotes in quirks mode?

查看:81
本文介绍了解决怪癖模式下的HTML剥离引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我试图在Javascript中使用InnerHTML时,Firefox会给出预期的结果。这样我就可以操纵dom元素,当我使用相同的工作代码时,IE会删除属性对中的引号。我想知道有没有解决这个问题的任何工作。如果可能的话,任何人都可以告诉我为什么会呈现,因为怪癖模式或什么?因为我在页面中有iframe。
DocType,我在我的页面中有。

when i tried to get as InnerHTML in Javascript, Firefox giving expected results. so that i can manipulate the dom elements, bu when i use the same working code, IE will strip out the quotation marks from the attribute pair. i am wondering is there any work around to solve this problem. and if possible can any body tell me why does it renders, because of quirks mode or what ? as i have iframes in pages. DocType which i have in my page.

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

预期:

Expected :

<span id="someID">Ravi <span class="SomeClass">assignment </span>submission</span>

输出

<span id=someID>Ravi <span class=SomeClass>assignment </span>submission</span>


推荐答案

<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> doesn' t引发怪癖模式,它会触发标准模式。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> doesn’t trigger quirks mode, it triggers standards mode just fine.

为什么缺少的引号会打扰您?如果你想操纵DOM元素,你不需要 innerHTML 字符串。

Why do the missing quotes bother you? If you want to manipulate the DOM elements, you don’t need the innerHTML string.

这篇关于解决怪癖模式下的HTML剥离引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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