onLoad not triggering in IE

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

    onLoad not triggering in IE

    Hi all,

    I¹ve been away from Javascript for awhile and am rusty, but this is too
    simple not to work! I¹m on a Mac, and usually use the Safari browser. I
    have a very basic web page in a frame. All it does is trigger a Perl
    script. Works great in Safari, does not work in IE or Netscape. In IE, the
    onLoad just doesn¹t seem to fire. I¹ve got to be looking right at the
    reason, but I¹m not seeing it. Help?

    (The live frameset is at
    http://www.wsc.ma.edu/webstudents/Co...e_frameset.htm .)

    TIA,
    Tery

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>comm test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <SCRIPT language="JavaS cript">
    function submitform()
    {
    document.form.s ubmit();
    }
    </SCRIPT>

    </head>

    <body bgcolor="#33009 9" onLoad="submitf orm()">

    <form name="form" action="randomi mages_2.pl">
    </form>
    </body>
    </html>

  • Dennis M. Marks

    #2
    Re: onLoad not triggering in IE

    In article <BCB08579.91D6% teryg-list@cox.net>, Tery Griffin
    <teryg-list@cox.net> wrote:
    [color=blue]
    > Hi all,
    >
    > I¹ve been away from Javascript for awhile and am rusty, but this is too
    > simple not to work! I¹m on a Mac, and usually use the Safari browser. I
    > have a very basic web page in a frame. All it does is trigger a Perl
    > script. Works great in Safari, does not work in IE or Netscape. In IE, the
    > onLoad just doesn¹t seem to fire. I¹ve got to be looking right at the
    > reason, but I¹m not seeing it. Help?
    >
    > (The live frameset is at
    > http://www.wsc.ma.edu/webstudents/Co...e_frameset.htm .)
    >
    > TIA,
    > Tery
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    > "http://www.w3.org/TR/html4/loose.dtd">
    > <html>
    > <head>
    > <title>comm test</title>
    > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    >
    > <SCRIPT language="JavaS cript">
    > function submitform()
    > {
    > document.form.s ubmit();
    > }
    > </SCRIPT>
    >
    > </head>
    >
    > <body bgcolor="#33009 9" onLoad="submitf orm()">
    >
    > <form name="form" action="randomi mages_2.pl">
    > </form>
    > </body>
    > </html>
    >[/color]
    It triggers in both IE5.1 and Netscape7.0 on my Mac with system 9 but
    you should add type="text/javascript" to the script tag.
    Also check if onLoad should be onload. All tags should be lowercase.

    --
    Dennis M. Marks

    Replace domain.invalid with dcsi.net


    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

    Comment

    • Tery Griffin

      #3
      Re: onLoad not triggering in IE

      On 4/24/04 9:32 PM, in article 240420041832127 557%denmarks@do main.invalid,
      "Dennis M. Marks" <denmarks@domai n.invalid> wrote:
      [color=blue]
      > It triggers in both IE5.1 and Netscape7.0 on my Mac with system 9 but
      > you should add type="text/javascript" to the script tag.
      > Also check if onLoad should be onload. All tags should be lowercase.[/color]


      Thanks Dennis. I made both changes. No difference for me. I'm on OS
      X.2.8, IE 5.3, Netscape 7.1. I'll be this happened with the switch to OS X.

      Tery

      Comment

      • Java  script  Dude

        #4
        Re: onLoad not triggering in IE

        Terry,

        I pretty much avoid using onLoad events any where. There always seems
        to be one browser that fails. Currently there is an open bug with
        Mozilla that I've been tracking - 99820.

        Instead now I now just add my own onLoad call. The following code
        after the closing body tag:

        <script>
        // Your'e onload script here.
        </script>

        I've had this on production and tested it on Mozilla (OSX, win32,
        Linux), IE (win32).

        There should be no reason that it will not work in Safari or IE Mac.

        BTW - For Cleanliness, I usually add a bodyLoaded function at the top
        of the page or in a JS file and call it from the script tag after the
        close body tag.

        Regards,

        Tim

        Comment

        • Richard Cornford

          #5
          Re: onLoad not triggering in IE

          Java script Dude wrote:
          <snip>[color=blue]
          > Instead now I now just add my own onLoad call. The following code
          > after the closing body tag:[/color]
          ^^^^^[color=blue]
          >
          > <script>
          > // Your'e onload script here.
          > </script>[/color]

          The HTML DTDs do not allow script elements to appear as children of the
          HTML element. The result of doing this is invalid HTML mark-up.
          [color=blue]
          > I've had this on production and tested it on Mozilla (OSX, win32,
          > Linux), IE (win32).
          >
          > There should be no reason that it will not work in Safari or IE Mac.[/color]
          <snip>

          There is every reason for expecting it to fail; if not in Safari or Mac
          IE then somewhere. There are no rules for the handling of invalid
          mark-up by web browsers so the browser is a liberty to do anything,
          including ignoring the out of context script element, and nobody could
          say it is wrong for it to do so. Relying on browser error-correcting
          cannot reasonably be recommended as a technique for achieving reliable
          results.

          Richard.


          Comment

          • Java  script  Dude

            #6
            Re: onLoad not triggering in IE

            > Richard Cornford wrote:[color=blue]
            > Java script Dude wrote:
            > <snip>[color=green]
            > > Instead now I now just add my own onLoad call. The following code
            > > after the closing body tag:[/color]
            > ^^^^^[color=green]
            > >
            > > <script>
            > > // Your'e onload script here.
            > > </script>[/color]
            >
            > There is every reason for expecting it to fail; if not in Safari or Mac
            > IE then somewhere. There are no rules for the handling of invalid
            > mark-up by web browsers so the browser is a liberty to do anything,
            > including ignoring the out of context script element, and nobody could
            > say it is wrong for it to do so. Relying on browser error-correcting
            > cannot reasonably be recommended as a technique for achieving reliable
            > results.[/color]

            I agree. If the end goal of the page is to work in a majority of the
            browsers that request it, this is not a good technique. But I think we
            are still years away when we (as developers) can make complex DHTML
            applications that work in a majority of browsers. To build really
            maintainable and effective DHTML Apps, the compatible browser list
            must be narrowed.

            At this time, Mozilla and IE never complain about putting code there
            and I am pretty sure with enough nagging, W3C could be convinced that
            it's not such a bad idea to allow script tags after the closing body
            tag. I have not had the time, nor the need, to test multiple browsers
            compatibility. Just IE 5.5sp2+ and Moz 1.3+. At least this could be
            used as a back door to the body's onload event.

            Maybe I'm way off here ?:]

            Comment

            • Richard Cornford

              #7
              Re: onLoad not triggering in IE

              Java script Dude wrote:[color=blue][color=green]
              >> Richard Cornford wrote:
              >> Java script Dude wrote:
              >><snip>[color=darkred]
              >>> Instead now I now just add my own onLoad call. The following code
              >>> after the closing body tag:[/color]
              >> ^^^^^[color=darkred]
              >>>
              >>> <script>
              >>> // Your'e onload script here.
              >>> </script>[/color][/color][/color]

              You have edited my post here without indicating that you have done so,
              moving my response to a direct statement of yours out of its original
              context.
              [color=blue][color=green]
              >> There is every reason for expecting it to fail; if not in Safari or
              >> Mac IE then somewhere. There are no rules for the handling of invalid
              >> mark-up by web browsers so the browser is a liberty to do anything,
              >> including ignoring the out of context script element, and nobody
              >> could say it is wrong for it to do so. Relying on browser
              >> error-correcting cannot reasonably be recommended as a technique for
              >> achieving reliable results.[/color]
              >
              > I agree. If the end goal of the page is to work in a majority of the
              > browsers that request it, this is not a good technique. But I think we
              > are still years away when we (as developers) can make complex DHTML
              > applications that work in a majority of browsers.[/color]

              That depends on how you define the majority of browsers. if it is just
              browsers in use then there are many who argue that IE is already the
              majority, if you mean the majority of distinct browsers then the
              majority are not javascript capable so DHTML was never going to work for
              them.
              [color=blue]
              > To build really
              > maintainable and effective DHTML Apps, the compatible browser list
              > must be narrowed.[/color]

              There are a number of practices that are known to impact on the
              reliability of browser scripts, one of which is the use of invalid
              mark-up. If DHTML support is going to be restricted then there really
              should be a better reason for reducing it below support for all
              javascript capable dynamic browsers than an unwillingness to author
              structurally valid HTML.
              [color=blue]
              > At this time, Mozilla and IE never complain about putting code there
              > and I am pretty sure with enough nagging, W3C could be convinced that
              > it's not such a bad idea to allow script tags after the closing body
              > tag.[/color]

              The expression "a snowball's chance in hell" springs to mind. The W3C
              seem to want to increase the requirements for formal correctness in web
              authoring (at least the move towards XHTML implies as much) and they
              also seem to like the idea of semantic mark-up. A primary document
              division of HEAD, BODY and SCRIPT, with script also allowed in many
              other contexts, would not sit well with that goal.
              [color=blue]
              > I have not had the time, nor the need, to test multiple browsers
              > compatibility. Just IE 5.5sp2+ and Moz 1.3+. At least this could be
              > used as a back door to the body's onload event.[/color]

              There is no fundamental problem with Mac OS X onload handlers in IE 5
              and Safari, they work fine when I test them. Where onload handlers fail
              is when a browser is used in conjunction with a
              content-inserting/re-writing proxy (personal firewalls and such like)
              with its settings configured to prevent onload (or sometimes onload
              generated pop-ups, where the onload script errors while failing to
              generate the pop-up), or on browsers like Mozilla which offer the user
              options to refuse the execution of onload/onunload events.

              But your invalid mark-up can be avoided by just moving the script
              element to just before the closing BODY tag, when all of the elements on
              the page will have been created in the DOM (if not maybe fully
              configured, especially in terms of dimensions and positions/offsets).

              Richard.


              Comment

              • Java  script  Dude

                #8
                Re: onLoad not triggering in IE

                > You have edited my post here without indicating that you have done so,[color=blue]
                > moving my response to a direct statement of yours out of its original
                > context.[/color]

                Sorry dude, my mistake.
                [color=blue]
                > But your invalid mark-up can be avoided by just moving the script
                > element to just before the closing BODY tag, when all of the elements on
                > the page will have been created in the DOM (if not maybe fully
                > configured, especially in terms of dimensions and positions/offsets).[/color]

                Good suggestion.

                I will try this technique. Nice thing about this technique is that the
                javascript thread executed could use document.writes where if after
                the closing body tag, you would have to use
                document.body.i nnerHTML+=... (or other similar method)

                To be honest, I cannot remember the exact browser that had the problem
                with the onload method. It was either on my OSX box (ibook) with
                Mozilla or on my win2k (dell) box with IE or Moz. The problem may
                actually have been fixed but at the time it pissed me off so much that
                I did bypass surgery on my pages and it's been working happily ever
                since.

                I realise that have been overly spoiled by working in a large but
                contained corporate intranet world. Your points on building standards
                based HTML is well taken.

                Thanks for your time and input.

                Tim

                Comment

                Working...