Javascript fails to work with xhtml 1.0 strict DTD

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Marsh

    Javascript fails to work with xhtml 1.0 strict DTD

    Hello everyone,

    I am attempting to create a xhtml page that uses a bit of dhtml.
    The javascript I am using uses
    document.getEle mentById('someI d').style.someP roperty; and is and
    external script. My page uses this dtd:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

    It validates at the wc3 validator as correct xhtml, but the problem is
    my script does not function. When I remove the dtd, the script
    functions as normal.

    I am obviously missing something here and would appreciate any
    feedback.

    Paul Marsh.
  • john henry bonham

    #2
    Re: Javascript fails to work with xhtml 1.0 strict DTD

    Paul Marsh wrote:
    [color=blue]
    > Hello everyone,
    >
    > I am attempting to create a xhtml page that uses a bit of dhtml.
    > The javascript I am using uses
    > document.getEle mentById('someI d').style.someP roperty; and is and
    > external script. My page uses this dtd:
    >
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    >
    > It validates at the wc3 validator as correct xhtml, but the problem is
    > my script does not function. When I remove the dtd, the script
    > functions as normal.
    >
    > I am obviously missing something here and would appreciate any
    > feedback.
    >
    > Paul Marsh.[/color]

    Link pls.

    Comment

    • Martin Honnen

      #3
      Re: Javascript fails to work with xhtml 1.0 strict DTD



      Paul Marsh wrote:

      [color=blue]
      > I am attempting to create a xhtml page that uses a bit of dhtml.
      > The javascript I am using uses
      > document.getEle mentById('someI d').style.someP roperty; and is and
      > external script. My page uses this dtd:
      >
      > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      >
      > It validates at the wc3 validator as correct xhtml, but the problem is
      > my script does not function. When I remove the dtd, the script
      > functions as normal.
      >
      > I am obviously missing something here and would appreciate any
      > feedback.[/color]

      What exactly are you trying to do? Which browser fails? An error
      messages or warning given by the browser?
      If you include such a DOCTYPE declaration browsers like Mozilla or
      Netscape 6/7 switch to standard compliants mode and therefore ignore
      things like
      element.style.l eft = 200
      as that is not correct CSS, a unit is missing so you need
      element.style.l eft = '200px';


      --

      Martin Honnen

      Comment

      • Richard Cornford

        #4
        Re: Javascript fails to work with xhtml 1.0 strict DTD

        Paul Marsh wrote:[color=blue]
        > I am attempting to create a xhtml page that uses a bit
        > of dhtml.[/color]

        A strange thing to do given how few scriptable dynamic browsers
        understand XHTML.
        [color=blue]
        > The javascript I am using uses
        > document.getEle mentById('someI d').style.someP roperty;
        > and is and external script. My page uses this dtd:
        >
        > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        >
        > It validates at the wc3 validator as correct xhtml, but the
        > problem is my script does not function. When I remove the dtd,
        > the script functions as normal.[/color]

        So you don't care to mention what "function as normal" constitutes, or
        how "does not function" differs?
        [color=blue]
        > I am obviously missing something here[/color]

        Yes; code, context and explanation. Indeed this is a case for a URL to
        the page (or a cut down page demonstrating the problem alone) because it
        isn't even certain that you are creating an XHTML document, rather than
        a malformed HTML document that syntactically resembles XHTML, and there
        for it isn't possible to tell if it is an HTML DOM or an XHTML DOM that
        you are actually scripting.
        [color=blue]
        > and would appreciate any feedback.[/color]

        Without any pertinent information to go on any answer is ginning to be a
        guess. And given that there are probably an infinite number of ways of
        creating erroneous and fragile scripts a guess is such a long shot that
        it is hardly worth writing, and definitely doesn't warrant any
        explanation:-

        The formal doctype is putting the browser into 'CSS1Compat' mode and the
        assignments of non-zero values to dimensions-type style properties do
        not include the required units declaration.

        Richard.


        Comment

        • Paul Marsh

          #5
          Re: Javascript fails to work with xhtml 1.0 strict DTD

          Hi Richard,

          yes in hindsight of course I should have included some additional
          info... it was my first post and I'll be sure to
          be more careful next time.

          As for this: "A strange thing to do given how few scriptable dynamic
          browsers understand XHTML."

          That's a fairly negitive tone, I'm here 'cause I don't know all the
          answers.

          You complain that it's not certain my document is xhtml, but I mentioned
          in my post that it validates at the wc3 validator as correct xhtml.

          Anyway, it works now that I have declared the units so thanks, but you
          should probably get out more.

          Paul.

          *** Sent via Developersdex http://www.developersdex.com ***
          Don't just participate in USENET...get rewarded for it!

          Comment

          • Paul Marsh

            #6
            Re: Javascript fails to work with xhtml 1.0 strict DTD

            Hi Martin,

            yes, now that I have declared the units it works. I'll be sure to
            include more detailed information in future posts.
            Thanks for your reply, I'd better go do some more reading!

            Paul.


            *** Sent via Developersdex http://www.developersdex.com ***
            Don't just participate in USENET...get rewarded for it!

            Comment

            • Richard Cornford

              #7
              Re: Javascript fails to work with xhtml 1.0 strict DTD

              Paul Marsh wrote:[color=blue]
              > Hi Richard,
              > yes in hindsight of course I should have included some
              > additional info... it was my first post and I'll be
              > sure to be more careful next time.
              >
              > As for this: "A strange thing to do given how few scriptable
              > dynamic browsers understand XHTML."
              >
              > That's a fairly negitive tone, I'm here 'cause I don't
              > know all the answers.[/color]

              Words of warning have a tendency to be negative.
              [color=blue]
              > You complain that it's not certain my document is xhtml, but I
              > mentioned in my post that it validates at the wc3 validator as
              > correct xhtml.[/color]

              That is totally irrelevant to a web browser, if you send a content-type
              header of text/html then the browser sees the document as (malformed)
              HTML and builds an HTML DOM to be scripted. And if you send a correct
              XHTML content-type header IE browsers cannot display the results, making
              that a non-viable option in a commercial contexts. Which leaves
              server-side content negotiation as the only way of using real XHTML and
              accommodating IE, with the consequence that you will probably also need
              to send a different script designed to work with each of the two types
              of DOM (and that is a lot of extra effort in order to use XHTML, with
              extremely questionable returns).
              [color=blue]
              > Anyway, it works now that I have declared the units so thanks,
              > but you should probably get out more.[/color]

              Shoot yourself in the foot, why don't you? Welcome to the George Hester
              filter.

              Richard.


              Comment

              • cwdjr

                #8
                Re: Javascript fails to work with xhtml 1.0 strict DTD

                I have converted several old dhtml codes from the browser war era to
                modern single path getElementById. It is very common to find problems
                with codes from this era when you clean them up for a specific
                Doctype. For example, after you strip layers and document.all support
                from one of the fireworks scripts at DynamicDrive and clean it up to
                4.01 transitional standards, all is fine on several modern browsers.
                However if you just change to html 4.01 strict with the DOCTYPE
                required for it, the script fails completely on some browsers. The
                problem in such cases usually can be traced down to the CSS. I have
                seen units such as px used for top and left, but not for width and
                height. For moving things, I have seen such as blah.left=40 or
                blah.left=x instead of the now required blah.left=40px or
                blah.left=x+'px ' . The faulty codes often will work on the IE6
                browser, but not on Opera and the Mozilla family - Big
                Mozilla(Mozilla ), Baby Mozilla(FireFox ), and Fat Mozilla(Netscap e). So
                the place I start when I have this sort of problem is to check
                everything in the script and html that has anythig to do with CSS and
                ask myself if the expression needs a unit in addition to a number.

                Comment

                Working...