contentEditable on nodes in a XML/compound document?

后端 未结 3 1898
难免孤独
难免孤独 2021-01-28 23:45

I have an XML document that I\'m displaying in a web browser, with a stylesheet attached:


<         


        
相关标签:
3条回答
  • 2021-01-29 00:08

    contentEditable works (tested in Firefox and Chrome) on elements which are foreign to html/xhtml if I use this doctype:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                          "http://www.w3.org/TR/html4/loose.dtd">
    

    and a .html file extension (instead of .xml).

    I don't have to include any html elements at all (eg head, body, div, p).

    css isn't applied though (if my xml is in a namespace, which i guess makes sense, given the doctype!).

    Not an elegant solution.

    0 讨论(0)
  • 2021-01-29 00:24

    In Firefox 3, @content-editable="true" only makes the relevant element editable if the content type is text/html (which also happens if a local filename ends with .html)

    It doesn't work for content types app/xhtml+xml or text/xml (local filenames ending with .xhtml or .xml)

    I've logged an enhancement for this: https://bugzilla.mozilla.org/show_bug.cgi?id=486931

    0 讨论(0)
  • 2021-01-29 00:25

    Firefox is one of the few browsers that strictly enforces the XHTML spec. So, to make an element editable, you must specify the contenteditable attribute as true. Note that the whole attribute name is lower case. In your example the first "E" in editable was capitalized.

    Another quirk that should be mentioned is that IE(6,7,8) act exactly the opposite. To make an element editable in IE, you MUST add contentEditable="true" exactly. For what ever reason, contenteditable="true" (as well as any other variation in capitalization) does not work.

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