Javascript failing xhtml [xhtml newbe]

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jean Pierre Daviau

    Javascript failing xhtml [xhtml newbe]

    Hi,

    <script language="javas cript" type="text/javascript">
    if(navigator.ap pName.indexOf(" Netscape") != -1){
    document.writel n('<link rel="stylesheet " href="~styles/aquarelle_ns.cs s"
    type="text/css" media="screen" title="base" />');
    }else{
    document.write( '<link rel="stylesheet " href="~styles/aquarelle.css"
    type="text/css" media="screen" title="base" />');
    }
    </script>

    <style type="text/css">
    ....
    </style>
    </head>
    ------------------------------------
    Error Line 39 column 118: document type does not allow element "link" here.
    ....xt/css" media="screen" title="base" />');The element named above was
    found in a context where it is not allowed. This could mean that you have
    incorrectly nested elements -- such as a "style" element in the "body"
    section instead of inside "head" -- or two elements that overlap (which is
    not allowed).

    One common cause for this error is the use of XHTML syntax in HTML
    documents. Due to HTML's rules of implicitly closed elements, this error can
    create cascading effects. For instance, using XHTML's "self-closing" tags
    for "meta" and "link" in the "head" section of a HTML document may cause the
    parser to infer the end of the "head" section and the beginning of the
    "body" section (where "link" and "meta" are not allowed; hence the reported
    error).

    What can I do?


    NB: The html form of it


    --

    X trĂªme newbe
    .......
    masm32
    windows Xp
    asus p4 s533/333/133
    Intel(R) Celeron (R) CPU 2.00 GHz


  • David Dorward

    #2
    Re: Javascript failing xhtml [xhtml newbe]

    Jean Pierre Daviau wrote:


    [ inside a <script> ][color=blue]
    > Error Line 39 column 118: document type does not allow element "link"
    > here. ...xt/css" media="screen" title="base" />');[/color]




    --
    David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is

    Comment

    • Benjamin Niemann

      #3
      Re: Javascript failing xhtml [xhtml newbe]

      Jean Pierre Daviau wrote:
      [color=blue]
      > Hi,
      >
      > <script language="javas cript" type="text/javascript">
      > if(navigator.ap pName.indexOf(" Netscape") != -1){
      > document.writel n('<link rel="stylesheet " href="~styles/aquarelle_ns.cs s"
      > type="text/css" media="screen" title="base" />');
      > }else{
      > document.write( '<link rel="stylesheet " href="~styles/aquarelle.css"
      > type="text/css" media="screen" title="base" />');
      > }
      > </script>
      >
      > <style type="text/css">
      > ...
      > </style>
      > </head>
      > ------------------------------------
      > [snip][/color]

      The most important issue: document.writel n() does not work in XHTML, if it's
      served as application/xhtml+xml. I assume that you are going to do this (at
      least with content negotiation, for browsers that support it), because
      XHTML is just another form of tagsoup, if served as text/html.

      Script snippets that contain '<' or '&' characters must be enclosed in
      <[CDATA[ .. ]]> marked sections, otherwise the validator will not parse the
      document as you intend it to do (browsers are more tolerant, but I would
      not count on it).

      This does not happen, if you stick to HTML, because the STYLE element has
      the content model CDATA, which means that the parser ignores (e.g. does not
      interpret a '<' as the start of a tag) everything until it finds the first
      '</' followed by a character 'a..z' or 'A..Z'.

      --
      Benjamin Niemann
      Email: pink at odahoda dot de
      WWW: http://www.odahoda.de/

      Comment

      • Jean Pierre Daviau

        #4
        Re: Javascript failing xhtml [xhtml newbe]


        | http://www.w3.org/TR/xhtml1/#h-4.8
        | http://www.hixie.ch/advocacy/xhtml


        How come this page validate sending
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        It does not use the crazy CDAT[[]]?





        Comment

        • David Dorward

          #5
          Re: Javascript failing xhtml [xhtml newbe]

          Jean Pierre Daviau wrote:
          [color=blue]
          > How come this page validate sending
          > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
          > />
          > It does not use the crazy CDAT[[]]?[/color]

          (a) That meta tag is mostly rubbish and the real http header will trump it
          every time

          (b) Validation checks conformance to the DTD. That is entirely independent
          of the content type.

          (c) You said it didn't validate!

          --
          David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
          Home is where the ~/.bashrc is

          Comment

          • Jean Pierre Daviau

            #6
            Re: Javascript failing xhtml [xhtml newbe]

            [color=blue]
            > (c) You said it didn't validate![/color]
            Dont misunderstand me, I am just trying to figure out :-)

            I did not express myself well.

            I was talking about mypage http://www.jeanpierredaviau.com/echangeTidy.html

            not this one:


            ............... ......
            exerp:
            <?xml version="1.0"?>
            <!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"> <head>
            <title>kgreene. com :: World boundaries plotter project.</title>
            <script type="text/Javascript" src="map.js"></script>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
            ............... ...


            Does not it send text/html content? It is suppose to be useless has I red
            in the article you refered me.

            ======
            If you use XHTML, you should deliver it with the application/xhtml+xml
            MIME type. If you do not do so, you should use HTML4 instead of XHTML.
            The alternative, using XHTML but delivering it as text/html, causes
            numerous problems that are outlined below.
            ==============


            My question is: is xhtml possible?


            Comment

            • David Dorward

              #7
              Re: Javascript failing xhtml [xhtml newbe]

              Jean Pierre Daviau wrote:

              [color=blue]
              > Does not it send text/html content?[/color]

              Yes, but that has nothing to do with the <meta> tag you put in it.
              [color=blue]
              > It is suppose to be useless has I red in the article you refered me.[/color]

              Sending XHTML as text/html gives you none of the benefits of XHTML (which
              are of use to only a very small proportion of authors today anyway), and is
              actively harmful in those (admittedly small proportion of) browsers which
              implement HTML correctly.
              [color=blue]
              > My question is: is xhtml possible?[/color]

              In 2005 it is mostly pointless and rather impractical.

              --
              David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
              Home is where the ~/.bashrc is

              Comment

              • Jean Pierre Daviau

                #8
                Re: Javascript failing xhtml [xhtml newbe]

                [color=blue]
                > In 2005 it is mostly pointless and rather impractical.[/color]

                I beleive you :-)

                Thanks


                Comment

                Working...