Firefox innerHTML bug?

Discussion in 'Javascript' started by nilsandi, Sep 25, 2007.

  1. nilsandi

    nilsandi Guest

    Hi folks,

    I have a problem using Mozilla Firefox 2.0.0.7 and the innerHTML
    function.
    I am using custom tags in my application, which are to be found and
    parsed by some javaScript program, which translates them into proper
    HTML.
    The contents of the XHTML document is as folows:

    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:tf >
    <head>
    <meta http-equiv="Content-Type" content="application/xml+xhtml;
    charset=utf-8" />
    <script type="text/javascript" src="js/transform.js"></script>
    </head>
    <body onload="transform();">
    <tf:form serv="...">
    <tf:anchor xpath="..." />
    Open account:
    <tf:list xpath="..." /><br />
    <ul>
    <li><a href="...">Link</a></li>
    </ul>
    </tf:form>
    </body>
    </html>


    In the JavaScript program, I get the contents of the BODY tag as
    follows:
    node = document.getElementsByTagName('body')[0];
    contents = node.innerHTML;

    But in this case, an alert(contents); or using firebug delivers the
    following as the body's innerHTML:



    <tf:form serv="...">
    <tf:anchor xpath="..." />
    Mandanten öffnen:
    <tf:list xpath="...">
    <br />
    </tf:list>
    </tf:anchor>
    </tf:form>
    <ul>
    <li><a href="...">Link</a></li>
    </ul>


    which is curious, because the <ul>-Tag (the enumeration) is no longer
    encapsed by the <tf:form>-Tag. Why?
    Note that I have set the xml namespace Prefix, but I can't figure out
    what I've done wrong so far.

    Anyone got suggestions?
    Thank you in advance.

    Bye, Nils
    nilsandi, Sep 25, 2007
    #1
    1. Advertising

  2. nilsandi

    Henry Guest

    On Sep 25, 3:22 pm, nilsandi <> wrote:
    <snip>
    > The contents of the XHTML document is as folows:


    Your document is not XHTML it is tag soup HTML (if not innerHTML would
    be a non-starter).

    <snip>
    > <tf:anchor xpath="..." />

    ^^
    Tag soup HTML parsers tend to disregard this XML style empty element
    mark up, and instead take <XXXXX /> as a single instance of an opening
    tag. Inferring any corresponding closing tags as required.
    <snip>
    > But in this case, an alert(contents); or using firebug delivers the
    > following as the body's innerHTML:
    >
    > <tf:form serv="...">
    > <tf:anchor xpath="..." />
    > Mandanten ?ffnen:
    > <tf:list xpath="...">
    > <br />
    > </tf:list>
    > </tf:anchor>
    > </tf:form>
    > <ul>
    > <li><a href="...">Link</a></li>
    > </ul>
    >
    > which is curious, because ...


    Given that input, any outcome from an HTML parser should be seen as
    unexpected. There are certainly no grounds for expecting any one thing
    rather than any other.
    Henry, Sep 25, 2007
    #2
    1. Advertising

  3. On Sep 25, 7:22 am, nilsandi <> wrote:
    > Hi folks,
    >
    > I have a problem using Mozilla Firefox 2.0.0.7 and the innerHTML
    > function.
    > I am using custom tags in my application, which are to be found and
    > parsed by some javaScript program, which translates them into proper
    > HTML.
    > The contents of the XHTML document is as folows:
    >
    > <html xmlns="http://www.w3.org/1999/xhtml" xmlns:tf >


    Why try to use XHTML?

    <URL: http://www.thewebcreator.net/2007/04/16/why-you-should-be-using-html-401-instead-of-xhtml/>

    <URL: http://www.webdevout.net/articles/beware-of-xhtml>

    Peter
    Peter Michaux, Sep 26, 2007
    #3
  4. Peter Michaux wrote:
    > On Sep 25, 7:22 am, nilsandi <> wrote:
    >> I have a problem using Mozilla Firefox 2.0.0.7 and the innerHTML
    >> function.
    >> I am using custom tags in my application,


    Elements, not tags.

    >> which are to be found and parsed by some javaScript program, which
    >> translates them into proper HTML.


    Only JavaScript (Netscape/Gecko), or any ECMAScript implementation?

    >> The contents of the XHTML document is as folows:
    >>
    >> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:tf >


    That is not a proper XML namespace declaration:

    http://www.w3.org/TR/REC-xml-names/#ns-decl
    http://www.w3.org/TR/REC-xml/#NT-Attribute

    > Why try to use XHTML?


    Probably because of the eXtensible? The OP's use indicates one of the rare
    valid reasons for preferring XHTML over HTML. However, the translation into
    HTML should be done server-side with XSLT or a template engine provided by
    the server maybe using that (even though that would be possible client-side
    as well). No need to reinvent the wheel worse than before.

    http://developer.mozilla.org/en/docs/XSLT


    PointedEars
    --
    "Use any version of Microsoft Frontpage to create your site. (This won't
    prevent people from viewing your source, but no one will want to steal it.)"
    -- from <http://www.vortex-webdesign.com/help/hidesource.htm>
    Thomas 'PointedEars' Lahn, Sep 26, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. webdev

    innerHTML not working in Firefox

    webdev, Oct 3, 2004, in forum: Javascript
    Replies:
    3
    Views:
    320
    Fred Oz
    Oct 3, 2004
  2. Brad

    FireFox/innerHTML and <area> tags

    Brad, Oct 29, 2004, in forum: Javascript
    Replies:
    1
    Views:
    116
    Jeff North
    Oct 30, 2004
  3. Clément
    Replies:
    6
    Views:
    95
    Clément
    Apr 11, 2006
  4. sonic
    Replies:
    5
    Views:
    270
    Randy Webb
    Jul 11, 2006
  5. Phper
    Replies:
    10
    Views:
    376
    John G Harris
    Sep 14, 2009
Loading...

Share This Page