解决 HTML 在怪异模式下剥离引号的问题吗?
当我尝试在 Javascript 中获取 InnerHTML 时,Firefox 给出了预期的结果。这样我就可以操作 dom 元素,但是当我使用相同的工作代码时,IE 会从属性对中去掉引号。我想知道是否有任何解决方法可以解决这个问题。如果可能的话,任何人都可以告诉我为什么它会渲染,因为怪癖模式还是什么?因为我的页面中有 iframe。 我的页面中有 DocType。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
预期:
<span id="someID">Ravi <span class="SomeClass">assignment </span>submission</span>
输出
<span id=someID>Ravi <span class=SomeClass>assignment </span>submission</span>
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>
Output
<span id=someID>Ravi <span class=SomeClass>assignment </span>submission</span>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
< /code> 不会触发怪异模式,它会触发标准模式。
为什么缺少的引号让您烦恼?如果您想操作 DOM 元素,则不需要
innerHTML
字符串。<!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.Why do the missing quotes bother you? If you want to manipulate the DOM elements, you don’t need the
innerHTML
string.