Work around for HTML stripping quotes in quirks mode?

和自甴很熟 提交于 2019-12-12 19:12:34

问题


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>

回答1:


<!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.



来源:https://stackoverflow.com/questions/9394318/work-around-for-html-stripping-quotes-in-quirks-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!