innerHTML removing closing slash from image tag

前端 未结 1 1070
遥遥无期
遥遥无期 2021-01-19 02:42

This is very odd. Here is a quick test function:

function test_function(){
    code = \'\"image\"\';         


        
相关标签:
1条回答
  • 2021-01-19 03:02

    The second alert just shows you what the browser uses as its internal representation of your image element. You don't need the slash for validation, as validation always is about your page's source, validators don't execute JavaScript that dynamically adds elements to the DOM.

    In fact, most browsers handle XHTML internally just the same as HTML, not as an XML-representation of your document. Only when you send your XHTML document with MIME-type application/xhtml+xml, some browsers will render your page using the XML parser.

    Also see Ian Hickson's article.

    0 讨论(0)
提交回复
热议问题