Proper DOCTYPE breaks JavaScript in IE9

Discussion in 'HTML' started by P E Schoen, Aug 8, 2012.

  1. P E Schoen

    P E Schoen Guest

    I've been playing with a simple HTML document which contains JavaScript in
    the <HEAD>. It worked fine without proper DOCTYPE, but when I fixed that so
    it validated, the JavaScript would not run. At first it was also broken in
    Firefox but I changed the DOCTYPE slightly as recommended on one forum and
    it worked - but still not in IE9.

    There's also a somewhat puzzling complaint about a </P> that passed
    validation in the first instance but not the second.

    Here's my HTML:
    http://www.enginuitysystems.com/ForceCalculator1.htm

    I start as follows:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
    <HEAD>
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" >
    <TITLE>Force Calculator</TITLE>

    <SCRIPT type="text/javascript"> //!-- Beginning of JavaScript -

    And the complaint is here (around line 150):

    <P>
    <h2>Torque, Power, and RPM</h2>
    <!-- </P> -->

    I referred to the following, but I note that the SCRIPT in the header is an
    external reference and the inline script is in the BODY. Maybe I'll try
    that.

    I haven't done anything with JavaScript (or HTML for that matter) for
    awhile, so I'm quite rusty. This may be an obvious error but I'm stumped for
    now.

    Thanks!

    Paul
    www.muttleydog.com
     
    P E Schoen, Aug 8, 2012
    #1
    1. Advertising

  2. P E Schoen

    P E Schoen Guest

    P E Schoen, Aug 8, 2012
    #2
    1. Advertising

  3. P E Schoen

    Doug Miller Guest

    "P E Schoen" <> wrote in news:jvs98h$iea$:

    > This simpler HTML page works OK in IE9:
    > http://www.enginuitysystems.com/CalculateJS1.htm
    >
    > But it has 8 errors and 2 warnings. That's a lot for 60 lines of highly
    > expanded HTML.


    Yes, that *is* rather a lot. Had you considered fixing them?
     
    Doug Miller, Aug 8, 2012
    #3
  4. P E Schoen

    P E Schoen Guest

    "Robert Baer" wrote in message
    news:...

    > Obviously all 12 or so digits for power and torque are significant and
    > meaningful...


    No, of course not. This is just a simple utility and not a polished product.
    Actually I have added some functionality and cleaned up some stuff, but
    still there is a problem with IE9:

    http://www.enginuitysystems.com/EVCalculator.htm

    Paul
     
    P E Schoen, Aug 8, 2012
    #4
  5. P E Schoen

    P E Schoen Guest

    "Doug Miller" wrote in message
    news:XnsA0A8DA4ABDF71dougmilmaccom@88.198.244.100...

    > "P E Schoen" <> wrote in news:jvs98h$iea$:


    >> This simpler HTML page works OK in IE9:
    >> http://www.enginuitysystems.com/CalculateJS1.htm

    >
    >> But it has 8 errors and 2 warnings. That's a lot for 60 lines of highly
    >> expanded HTML.


    > Yes, that *is* rather a lot. Had you considered fixing them?


    I can fix the errors by adding a DOCTYPE. But that breaks JavaScript for
    IE9.

    Paul
     
    P E Schoen, Aug 8, 2012
    #5
  6. P E Schoen

    P E Schoen Guest

    Re: Proper DOCTYPE breaks JavaScript in IE9 - solved

    I found that the keyword const is not allowed in Javascript, although
    apparently Firefox and Chrome allow it. The debugger complained about
    something else and then finally it continued to the const declaration where
    it reported a syntax error.

    So many languages. So much inconsistency...

    Paul
     
    P E Schoen, Aug 8, 2012
    #6
  7. P E Schoen

    Tim Streater Guest

    Re: Proper DOCTYPE breaks JavaScript in IE9 - solved

    In article <jvt94g$38c$>,
    "P E Schoen" <> wrote:

    > I found that the keyword const is not allowed in Javascript, although
    > apparently Firefox and Chrome allow it. The debugger complained about
    > something else and then finally it continued to the const declaration where
    > it reported a syntax error.
    >
    > So many languages. So much inconsistency...


    No, just the one. I observe that Safari is very forgiving, reporting no
    errors in the error console. Not only it doesn't mind your consts, it
    also allows you to do (e.g.):

    Form1.FormDate.value = EditDate;

    rather than:

    document.Form1.FormDate.value = EditDate;

    or even:

    document.forms["Form1"].FormDate.value = EditDate;

    OK, so you took out the consts. What happened then?

    --
    Tim

    "That excessive bail ought not to be required, nor excessive fines imposed,
    nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
     
    Tim Streater, Aug 8, 2012
    #7
  8. P E Schoen

    Doug Miller Guest

    "P E Schoen" <> wrote in news:jvt41n$9sh$:

    > "Doug Miller" wrote in message
    > news:XnsA0A8DA4ABDF71dougmilmaccom@88.198.244.100...
    >
    >> "P E Schoen" <> wrote in

    > news:jvs98h$iea$:
    >
    >>> This simpler HTML page works OK in IE9:
    >>> http://www.enginuitysystems.com/CalculateJS1.htm

    >>
    >>> But it has 8 errors and 2 warnings. That's a lot for 60 lines of

    > highly
    >>> expanded HTML.

    >
    >> Yes, that *is* rather a lot. Had you considered fixing them?

    >
    > I can fix the errors by adding a DOCTYPE.


    Really? What DOCTYPE is that?
     
    Doug Miller, Aug 8, 2012
    #8
  9. P E Schoen

    P E Schoen Guest

    "Doug Miller" wrote in message
    news:XnsA0A958E37BAEEdougmilmaccom@88.198.244.100...

    > "P E Schoen" <> wrote in news:jvt41n$9sh$:


    >> I can fix the errors by adding a DOCTYPE.


    > Really? What DOCTYPE is that?


    Almost any DOCTYPE. The validation errors were mostly related to that. But
    the broken JavaScript was due to other factors that did not affect
    validation.

    The problem(s) are fixed now, at least to the point where it works.

    Thanks,

    Paul
     
    P E Schoen, Aug 8, 2012
    #9
  10. P E Schoen

    Hot-Text Guest

    "P E Schoen" <> wrote in message news:jvs98h$iea$...
    > This simpler HTML page works OK in IE9:
    > http://www.enginuitysystems.com/CalculateJS1.htm
    >
    > But it has 8 errors and 2 warnings. That's a lot for 60 lines of highly
    > expanded HTML.
    >
    > Paul
    >


    Not
    <SCRIPT type="text/javascript">
    //!-- Beginning of JavaScript -

    // - End of JavaScript - -->
    </SCRIPT>

    But
    <SCRIPT type="text/javascript">
    <!--
    // Beginning of JavaScript -

    // - End of JavaScript
    //-->
    </SCRIPT>

    Have to be start <!-- to work in IE........
     
    Hot-Text, Aug 8, 2012
    #10
  11. Hot-Text wrote:

    > Not
    > <SCRIPT type="text/javascript">
    > //!-- Beginning of JavaScript -
    >
    > // - End of JavaScript - -->
    > </SCRIPT>
    >
    > But
    > <SCRIPT type="text/javascript">
    > <!--
    > // Beginning of JavaScript -
    >
    > // - End of JavaScript
    > //-->
    > </SCRIPT>


    No that is absolutely incorrect. The first is missing the leading "<"
    but is unnecessary you do not have to "hide" with HTML comments
    JavaScript within an HTML document, nor CSS within the STYLE element as
    many do. That was for a bug in an ancient, and I mean *ancient* version
    of Netscape.

    Your suggestion is wrong because between the opening and closing SCRIPT
    tags "plays" by JavaScript, not HTML syntax which are C, C+++ style:

    // valid JavaScript comment

    /* another JavaScript comment */

    not

    <!-- invalid JavaScript comment -->


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Aug 8, 2012
    #11
  12. P E Schoen

    P E Schoen Guest

    Re: Proper DOCTYPE breaks JavaScript in IE9 - solved

    "Robert Baer" wrote in message
    news:...

    > You really mean "so many versions of IE, an almost infinite amount of
    > inconsistency".


    No, I'm referring to the sometimes subtle and sometimes just puzzling and
    annoying differences in languages such as JavaScript, PHP, Perl, C, Delphi,
    and Visual Basic, to name a few. Strongly or loosely typed. Case sensitive
    or not. Things like that.

    But the browsers also contribute to the problem when they don't work the
    same.

    I mostly use C for microcontroller projects (assembler for simple stuff),
    Borland Delphi4 for Windows GUIs, JavaScript for client side scripts, PHP
    for server side scripts (I tried but didn't like Perl), VBA for application
    scripting, and sometimes VB or JS using the WSH for local machine scripts.
    It's difficult to remember the standards and quirks for each when switching
    back and FORTH (and that's another language!)

    Paul
     
    P E Schoen, Aug 10, 2012
    #12
  13. Re: Proper DOCTYPE breaks JavaScript in IE9 - solved

    P E Schoen wrote:
    > "Robert Baer" wrote in message
    > news:...
    >
    >> You really mean "so many versions of IE, an almost infinite amount
    >> of inconsistency".

    >
    > No, I'm referring to the sometimes subtle and sometimes just puzzling
    > and annoying differences in languages such as JavaScript, PHP, Perl, C,
    > Delphi, and Visual Basic, to name a few. Strongly or loosely typed. Case
    > sensitive or not. Things like that.
    >
    > But the browsers also contribute to the problem when they don't work the
    > same.
    >
    > I mostly use C for microcontroller projects (assembler for simple
    > stuff), Borland Delphi4 for Windows GUIs, JavaScript for client side
    > scripts, PHP for server side scripts (I tried but didn't like Perl), VBA
    > for application scripting, and sometimes VB or JS using the WSH for
    > local machine scripts. It's difficult to remember the standards and
    > quirks for each when switching back and FORTH (and that's another
    > language!)


    The same is true for "human" languages. Since humans created computer
    languages I would say "inconsistency" is in our nature! ;-)


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Aug 10, 2012
    #13
  14. P E Schoen

    P E Schoen Guest

    Re: Proper DOCTYPE breaks JavaScript in IE9 - solved

    "Jonathan N. Little" wrote in message news:k032gr$ukf$...

    > The same is true for "human" languages. Since humans created computer
    > languages I would say "inconsistency" is in our nature! ;-)


    At least K&R's C language and Pascal/Delphi were created with the idea of
    making them logical and consistent. They differ on some important points but
    otherwise they are fairly easy to understand and use. BASIC has always been
    a bit of a kludge, but it was pretty good for beginners and was adequate for
    simple programs and it was/is well suited to interpretive use.

    But then OOP became popular and C++ and VB seemed to be hacked to make them
    fit the need, but I think Delphi was easier to use because it was already a
    higher level language than C. But IMHO VB was never really consistent and
    powerful enough in its design, and Visual BASIC seems to be very quirky and
    unwieldy. DotNet I think was a further abomination.

    OTOH client side scripting with JavaScript seems close enough to C for me to
    be comfortable, but its quirks are rather annoying. And the popular server
    side scripting languages Perl and PHP seem to have been fudged and tweaked
    from the git-go by code monkeys who did not really have an overall plan and
    just used bits and pieces of other languages along with some of their own
    often questionable and obfuscating constructs such as "regular expressions".
    But at least they seem to have some consistency among the languages. Others
    such as Ruby seem to be "me-too" variations designed by young hotshot
    programmers to be useful for specific applications but not well enough
    designed to to be comprehensive and well structured.

    Oh, well, it is what it is. And I read an article recently praising the
    merits of Ada, which at least is similar to Pascal and has some nice
    features that make it easy to read and somewhat bug-resistant.

    Paul
     
    P E Schoen, Aug 10, 2012
    #14
  15. P E Schoen

    Hot-Text Guest

    "Jonathan N. Little" <> wrote in message news:jvupa2$62s$...
    > Hot-Text wrote:
    >
    >> Not
    >> <SCRIPT type="text/javascript">
    >> //!-- Beginning of JavaScript -
    >>
    >> // - End of JavaScript - -->
    >> </SCRIPT>
    >>
    >> But
    >> <SCRIPT type="text/javascript">
    >> <!--
    >> // Beginning of JavaScript -
    >>
    >> // - End of JavaScript
    >> //-->
    >> </SCRIPT>

    >
    > No that is absolutely incorrect. The first is missing the leading "<"
    > but is unnecessary you do not have to "hide" with HTML comments
    > JavaScript within an HTML document, nor CSS within the STYLE element as
    > many do. That was for a bug in an ancient, and I mean *ancient* version
    > of Netscape.
    >
    > Your suggestion is wrong because between the opening and closing SCRIPT
    > tags "plays" by JavaScript, not HTML syntax which are C, C+++ style:
    >
    > // valid JavaScript comment
    >
    > /* another JavaScript comment */
    >
    > not
    >
    > <!-- invalid JavaScript comment -->
    >


    /* Yes JavaScript comment */

    You a 100% Right Jonathan N. Little
     
    Hot-Text, Aug 11, 2012
    #15
    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. Replies:
    1
    Views:
    400
    Anon-E-Moose
    Sep 9, 2005
  2. Chris F.A. Johnson

    IE9

    Chris F.A. Johnson, Apr 1, 2009, in forum: HTML
    Replies:
    3
    Views:
    522
  3. cwdjrxyz
    Replies:
    2
    Views:
    810
    Beauregard T. Shagnasty
    Sep 24, 2010
  4. Garrett Smith

    javascript: psuedo-protocol side affects in IE9

    Garrett Smith, Jul 6, 2010, in forum: Javascript
    Replies:
    0
    Views:
    162
    Garrett Smith
    Jul 6, 2010
  5. Larry Lindstrom
    Replies:
    19
    Views:
    1,308
    Jonathan N. Little
    Jun 12, 2012
Loading...

Share This Page