Why this html doesn't work?

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

    Why this html doesn't work?

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

    <HTML>
    <HEAD>
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8"/
    >
    <TITLE>HTML to Text Test Page</TITLE>
    <SCRIPT type="text/javascript" src="test.js"/>
    <SCRIPT type="text/javascript">
    function onload(){
    alert("aaa");
    }
    </SCRIPT>
    </HEAD>
    <BODY>
    <DIV id="case1">
    <P>abc</P>
    <P>def</P>
    </DIV>
    </BODY>
    </HTML>
    The test.js is located in the same directory as that of the html file.
    The alert dialog doesn't appear.
    If I remove the line that includes the test.js file, the html file
    works, otherwise the alert dialog doesn't appear even if the test.js
    is empty.
    Thanks in advance.
  • Jukka K. Korpela

    #2
    Re: Why this html doesn't work?

    Scripsit ray:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    Post a URL, not a code extract.
    <SCRIPT type="text/javascript" src="test.js"/>
    Don't mix HTML and XHTML. Don't use XHTML on the web until you
    understand what XHTML actually is. (And when you do understand it, you
    don't need to be told not to use XHTML on the web.)

    Specifically, do you know what the above tag means in (non-XHTML) HTML
    and how it is processed by browsers treating your document as HTML?
    <SCRIPT type="text/javascript">
    function onload(){
    alert("aaa");
    }
    </SCRIPT>
    The content of the element defines a function in JavaScript. Do you
    expect the function to be called (invoked) when the page is loaded? Why?

    (You did not actually cut and paste the _real_ page, did you? This is
    one of the reasons why you should post a URL.)
    If I remove the line that includes the test.js file, the html file
    works, otherwise the alert dialog doesn't appear even if the test.js
    is empty.
    If "works" means that the alert("aaa") invocation is executed, I don't
    believe you.

    --
    Jukka K. Korpela ("Yucca")


    Comment

    • Gus Richter

      #3
      Re: Why this html doesn't work?

      ray wrote:
      <META http-equiv="Content-Type" content="text/html; charset=UTF-8"/ >
      Your document is an HTML document per the doctype declaration.
      The META element is an empty element without a closing tag.
      In XML, empty elements require a (fwd slash) terminator.
      In XHTML, open elements require (space + fwd slash) terminator.
      In HTML the META element should look so:
      <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <SCRIPT type="text/javascript" src="test.js"/>
      The SCRIPT element requires a closing tag in both HTML and XHTML,
      whether empty or not.
      In XML (I believe, since not into XML), an empty element has the closing
      tag dropped and the opening tag has a (fwd slash) terminator added.
      In HTML the SCRIPT element should look so:
      <SCRIPT type="text/javascript" src="test.js"></SCRIPT>
      If I remove the line that includes the test.js file, the html file
      works, otherwise the alert dialog doesn't appear even if the test.js
      is empty.
      With the closing tag it works.

      --
      Gus

      Comment

      • Roy A.

        #4
        Re: Why this html doesn't work?

        On 26 Mai, 04:53, ray <hanl...@gmail. comwrote:
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
                  "http://www.w3.org/TR/html4/strict.dtd">
        >
        <HTML>
          <HEAD>
            <META http-equiv="Content-Type" content="text/html; charset=UTF-8"/
        >
            <TITLE>HTML to Text Test Page</TITLE>
            <SCRIPT type="text/javascript" src="test.js"/>
        You should use a proper document type.

        It's considered best practise to read htmldog.com.
            <SCRIPT type="text/javascript">
              function onload(){
              alert("aaa");
              }
            </SCRIPT>
          </HEAD>
          <BODY>
            <DIV id="case1">
              <P>abc</P>
              <P>def</P>
            </DIV>
          </BODY>
        </HTML>
        The test.js is located in the same directory as that of the html file.
        The alert dialog doesn't appear.
        If I remove the line that includes the test.js file, the html file
        works, otherwise the alert dialog doesn't appear even if the test.js
        is empty.
        Thanks in advance.

        Comment

        • Eric B. Bednarz

          #5
          Re: Why this html doesn't work?

          "Roy A." <royarneskar@gm ail.comwrites:
          On 26 Mai, 04:53, ray <hanl...@gmail. comwrote:
          >    <META http-equiv="Content-Type" content="text/html; charset=UTF-8"/
          >>
          You should use a proper document type.
          Like PDF? :)
          It's considered best practise to read htmldog.com.
          Is that in the FAQ?

          (I think it is generally considered good pratice to use a nntp client
          for posting on Usenet, preferably one that does not mangle quoted code
          snippets, however inadequate they may be, but that is an entirely
          different problem)

          --
          "Note that the DOCTYPE tag is a bit of a rebel and demands to be written
          in upper case and adorned with an exclamation mark. It also breaks the
          rules in that it is the only tag that doesn't need closing."
          <http://htmldog.com/guides/htmladvanced/declarations/>
          [good stuff, no emphasis added —Ed.]

          Comment

          • Jukka K. Korpela

            #6
            Group FAQ &amp; Bogosities in htmldog.com

            Sub titulo Re: Why this html doesn't work?
            scripsit Eric B. Bednarz:
            >It's considered best practise to read htmldog.com.
            >
            Is that in the FAQ?
            Why do you ask? Because you are uncertain about the existence of a FAQ
            for this group? According to faqs.org, for whatever it's worth, the
            group has a FAQ at http://www.faqs.org/faqs/www/authoring-faq/ and the
            FAQ is posted monthly, last modified in 2001, last posted in 2002; ref.:

            But the FAQ there refers to
            The Web Design Group's Web Authoring FAQ addresses frequently asked questions related to HTML, images, style sheets, and other Web authoring issues.

            which was last updated on April 26, 2007.

            Generally, let's all sing "Oh where have all the FAQs gone", and let us
            be thankful to people who contributed to the FAQ and especially to Darin
            McGrew, who is apparently the last person keeping the FAQ somewhat
            alive.
            (I think it is generally considered good pratice to use a nntp client
            for posting on Usenet, preferably one that does not mangle quoted code
            snippets, however inadequate they may be, but that is an entirely
            different problem)
            Right. But I think it's not good practice to hide the most important
            content of a message into a sig. You sig says:

            "Note that the DOCTYPE tag is a bit of a rebel and demands to be written
            in upper case and adorned with an exclamation mark. It also breaks the
            rules in that it is the only tag that doesn't need closing."
            <http://htmldog.com/guides/htmladvanced/declarations/>
            [good stuff, no emphasis added —Ed.]

            Technically, it exceeds the four-line limit. More importantly, it is
            apparently ironic, but not apparently enough, since most HTML authors,
            even including those who read the group, are more or less clueless about
            doctype declarations. Sorry if this insults someone, but it's still
            true. I am clueless about most things in world, and I don't mind if
            people point that out. (Strangely enough, though, I'm usually accused
            for being clueless in matters that I actually know pretty well. Strange
            world, isn't it?)

            Anyway, let's be explicit about the goofs in the quoted text:
            1) The doctype declaration is not a tag at all (so the last sentence in
            the quoted text is nonsense).
            2) It is not case-sensitive, though some parts of it are.
            3) The "funny" wordings aren't funny, and an explanation like that
            wouldn't be a right place to be funny.

            Otherwise, the page from which the quotation was taken tells what the
            XHTML doctype declarations are and babbles about them. This is
            counter-productive. It also says:

            "Without specifying a doctype, your HTML just isn't valid HTML and most
            browsers viewing them will switch to 'quirks mode', which means they
            will think that you don't know what the hell you're doing and make up
            their own mind on what to do with your code."

            The text makes a point and then quickly loses it, describing "quirks
            mode" in wrong terms and without citing any information on what "quirks
            mode" actually means. It does not even warn that adding a doctype
            declaration to an existing page may completely ruin the page (for
            example, all content turns invisible), unless the page is fixed to use
            proper HTML and proper CSS, which is rather nontrivial task.

            I'm not saying that the author is "a short-sighted, one-eyed infant
            gibbon with learning difficulties", as he describes a hypothetical web
            author, but that's mainly due to my respect for people with learning
            difficulties and for our simian relatives.

            I had a positive impression of htmldog.com, from other people's comments
            and from a quick look at the surface. This surely opened my eyes.

            --
            Jukka K. Korpela ("Yucca")


            Comment

            • Jonathan N. Little

              #7
              Re: Group FAQ &amp; Bogosities in htmldog.com

              Jukka K. Korpela wrote:
              Sub titulo Re: Why this html doesn't work?
              scripsit Eric B. Bednarz:
              >
              >>It's considered best practise to read htmldog.com.
              < snip>
              Otherwise, the page from which the quotation was taken tells what the
              XHTML doctype declarations are and babbles about them. This is
              counter-productive. It also says:
              >
              "Without specifying a doctype, your HTML just isn't valid HTML and most
              browsers viewing them will switch to 'quirks mode', which means they
              will think that you don't know what the hell you're doing and make up
              their own mind on what to do with your code."
              >
              The text makes a point and then quickly loses it, describing "quirks
              mode" in wrong terms and without citing any information on what "quirks
              mode" actually means. It does not even warn that adding a doctype
              declaration to an existing page may completely ruin the page (for
              example, all content turns invisible), unless the page is fixed to use
              proper HTML and proper CSS, which is rather nontrivial task.
              >
              I'm not saying that the author is "a short-sighted, one-eyed infant
              gibbon with learning difficulties", as he describes a hypothetical web
              author, but that's mainly due to my respect for people with learning
              difficulties and for our simian relatives.
              >
              I had a positive impression of htmldog.com, from other people's comments
              and from a quick look at the surface. This surely opened my eyes.
              >
              There is little out there either online or in print that gives newbies
              the proper modern approach. It is disappointing section on their site.
              However, other parts are best that I have seen online. Guess we cannot
              have perfection. Would welcome the discovery of anything better...but
              until that I would say that www.htmldog.com tutorials are best(*
              although not perfect) to be found, and far better then most.

              --
              Take care,

              Jonathan
              -------------------
              LITTLE WORKS STUDIO

              Comment

              • Eric B. Bednarz

                #8
                Re: Group FAQ &amp; Bogosities in htmldog.com

                "Jukka K. Korpela" <jkorpela@cs.tu t.fiwrites:
                scripsit Eric B. Bednarz:
                >
                >>It's considered best practise to read htmldog.com.
                >>
                >Is that in the FAQ?
                >
                Why do you ask? Because you are uncertain about the existence of a FAQ
                for this group?
                It was more of a joke (these days you never know, though :).
                Right. But I think it's not good practice to hide the most important
                content of a message into a sig.
                I wouldn’t say it’s the most important content. Mind me, if it’s not
                just plain old good but best practice, I’d really like to learn more
                about the whereabouts of those who appear to consider that. You may
                consider the question ironic too, if you must. :) Frankly, I find
                htmldog a pretty lousy resource, but didn’t feel pressed to say that in
                a straightforward manner.

                Besides the excellent advice to exclusively declare language on the web
                with the xml:lang MacGuffin, did you notice the PHP BS at the end of
                that page, by the way?

                | <?
                | if(stristr(\$_S ERVER["HTTP_ACCEP T"],"applicatio n/xhtml+xml")){
                | header("Content-Type: application/xhtml+xml; charset=UTF-8");
                <http://htmldog.com/guides/htmladvanced/declarations/>

                There’s so much wrong with it that you could build an entire Web 2.0
                conference around it. As to the conclusion

                | Other than peace of mind that you know you're doing the right thing
                | and preparing yourself for the way to do things in the future, the
                | immediate benefit of using this method is that Mozilla will treat your
                | files as XML applications […]

                I’m glad to say that this *is* in the FAQ.

                <http://www.mozilla.org/docs/web-developer/faq.html#accept >
                (Strangely enough, though, I'm usually
                accused for being clueless in matters that I actually know pretty
                well. Strange world, isn't it?)
                Dunno. Actually, one of the reasons why I despise all the web standards
                yada yada is that the most vocal proponents typically didn’t read any of
                that boring stuff that they are evangelizing. It is pretty easy to get
                into hopeless arguments with them, especially if you did your
                homework. As I see it, that leads to either frustration or amusement. I
                learned to prefer the latter; it was tough, but it worked out :)


                --
                ||| hexadecimal EBB
                o-o decimal 3771
                --oOo--( )--oOo-- octal 7273
                205 goodbye binary 111010111011

                Comment

                • Andy Dingley

                  #9
                  Re: Group FAQ &amp; Bogosities in htmldog.com

                  On 29 May, 11:27, "Jukka K. Korpela" <jkorp...@cs.tu t.fiwrote:
                  I am clueless about most things in world, and I don't mind if
                  people point that out. (Strangely enough, though, I'm usually accused
                  for being clueless in matters that I actually know pretty well.
                  So that makes you smarter than Plato?

                  Few dispute your cluefulness in the areas you discuss. If you're
                  accused of cluelessness, might I suggest that it's your
                  communication skills that are falling short, not your understanding.

                  Comment

                  • Jukka K. Korpela

                    #10
                    Re: Group FAQ &amp; Bogosities in htmldog.com

                    Scripsit Andy Dingley:
                    might I suggest that it's your
                    communication skills that are falling short, not your understanding.
                    You might, but then you would express something about _your_ manners and
                    skills in communication. Like I would if I started babbling my guesses
                    about your personality.

                    --
                    Jukka K. Korpela ("Yucca")


                    Comment

                    • dorayme

                      #11
                      Re: Group FAQ &amp; Bogosities in htmldog.com

                      In article
                      <6bd907d2-3632-41f0-8ee8-eed86ec07a12@j2 2g2000hsf.googl egroups.com>,
                      Andy Dingley <dingbat@codesm iths.comwrote:
                      On 29 May, 11:27, "Jukka K. Korpela" <jkorp...@cs.tu t.fiwrote:
                      >
                      I am clueless about most things in world...
                      >
                      >
                      ... I suggest that it's your
                      communication skills that are falling short, not your understanding.
                      The two things, in certain defined areas - namely understanding the
                      ordinary "other" human mind - are connected so tightly that one cannot
                      so easily separate them. So, in this respect, but not in any other, it
                      suggests a misplaced flattery.

                      --
                      dorayme

                      Comment

                      • dorayme

                        #12
                        Re: Group FAQ &amp; Bogosities in htmldog.com

                        In article <YoX%j.9613$_03 .3478@reader1.n ews.saunalahti. fi>,
                        "Jukka K. Korpela" <jkorpela@cs.tu t.fiwrote:
                        Scripsit Andy Dingley:
                        >
                        might I suggest that it's your
                        communication skills that are falling short, not your understanding.
                        >
                        You might, but then you would express something about _your_ manners and
                        skills in communication. Like I would if I started babbling my guesses
                        about your personality.
                        So much for the good natured aspect of AD's remark. Not only what is it
                        not seen to be flattering - the only respect, paradoxically, in which it
                        was false - but it simply fell on deaf ears and so enhanced its
                        credibility.

                        --
                        dorayme

                        Comment

                        • Jukka K. Korpela

                          #13
                          Re: Group FAQ &amp; Bogosities in htmldog.com

                          Scripsit Eric B. Bednarz:
                          Besides the excellent advice to exclusively declare language on the
                          web with the xml:lang MacGuffin, did you notice the PHP BS at the end
                          of that page, by the way?
                          No, I didn't read that carefully. I usually read text carefully only if
                          it has been written carefully, unless I am specifically paid for reading
                          it.

                          Thanks for the amusement.

                          But I'm afraid people's irony detectors might not be working, so they
                          might take your praise at face value. After all, they keep hearing that
                          XML and XHTML are solutions to everything and the way of the future we
                          should have taken years ago and they are semantic and free of errors and
                          extensible and everythingable.

                          Few people can tell a single _correct_ example of _actual_ benefits from
                          the use of language markup in HTML documents. One reason to that is that
                          the benefits are so limited. Another reason is that nobody ever
                          presented factually correct examples, still less demonstrated them.
                          People who can repeat the claim that language markup helps in speech
                          synthesis typically haven't ever actually _heard_ this is in action. So
                          no wonder they see nothing wrong with examples that use xml:lang (only).

                          Let us consider one actual benefit: if you open an HTML document in
                          Microsoft Word (or even copy and paste data from a web page to Word),
                          language markup gets transferred into Word's internal information about
                          language. This is useful for spelling and grammar checking (Word
                          automatically applies the rules of the languages used), for automatic
                          hyphenation, etc. Now guess (twice, if needed) whether Word recognizes
                          lang="..." or xml:lang="...". Or just try it.

                          --
                          Jukka K. Korpela ("Yucca")


                          Comment

                          • ray

                            #14
                            Re: Why this html doesn't work?

                            On May 26, 5:41 pm, Gus Richter <gusrich...@net scape.netwrote:
                            ray wrote:
                             <META http-equiv="Content-Type" content="text/html; charset=UTF-8"/ >
                            >
                            Your document is an HTML document per the doctype declaration.
                            The META element is an empty element without a closing tag.
                            In XML, empty elements require a (fwd slash) terminator.
                            In XHTML, open elements require (space + fwd slash) terminator.
                            In HTML the META element should look so:
                            <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
                            >
                                <SCRIPT type="text/javascript" src="test.js"/>
                            >
                            The SCRIPT element requires a closing tag in both HTML and XHTML,
                            whether empty or not.
                            In XML (I believe, since not into XML), an empty element has the closing
                            tag dropped and the opening tag has a (fwd slash) terminator added.
                            In HTML the SCRIPT element should look so:
                            <SCRIPT type="text/javascript" src="test.js"></SCRIPT>
                            >
                            If I remove the line that includes the test.js file, the html file
                            works, otherwise the alert dialog doesn't appear even if the test.js
                            is empty.
                            >
                            With the closing tag it works.
                            >
                            --
                            Gus
                            Great! Thanks.

                            Comment

                            Working...