event handlers in IE5

Discussion in 'Javascript' started by Andrew Poulos, Dec 7, 2004.

  1. Sorry for the re-post but the original message subject no longer
    applies. If I try this in IE5, it doesn't work:

    <script type="text/javascript">
    window.onload = foo;
    </script>
    <body>

    whereas this does work:

    <body onload="javascript:foo();">

    This is not the way I want to handle events. I checked MSDN and it seems
    to indicate that the first way should work. Is there something I can do
    to get the first way (event handlers?) to work in IE5?

    Andrew Poulos
    Andrew Poulos, Dec 7, 2004
    #1
    1. Advertising

  2. Andrew Poulos wrote:
    > Sorry for the re-post but the original message subject no longer
    > applies. If I try this in IE5, it doesn't work:
    >
    > <script type="text/javascript">
    > window.onload = foo;
    > </script>
    > <body>


    Why not? Do you have a foo function defined? What happens?
    Works for me (but only, if there is no onload attribute set for the body
    element).


    > whereas this does work:
    >
    > <body onload="javascript:foo();">


    The onload attribute is allready defined to contain script. You don't
    need to use the javascript pseudoprotocoll here.

    <body onload="foo();">

    Daniel
    Daniel Kirsch, Dec 7, 2004
    #2
    1. Advertising

  3. Daniel Kirsch wrote:

    > Andrew Poulos wrote:
    >
    >> Sorry for the re-post but the original message subject no longer
    >> applies. If I try this in IE5, it doesn't work:
    >>
    >> <script type="text/javascript">
    >> window.onload = foo;
    >> </script>
    >> <body>

    >
    > Why not? Do you have a foo function defined? What happens?
    > Works for me (but only, if there is no onload attribute set for the body
    > element).


    I've test a few other things and I may having looking in the wrong place
    for the bug(s). My actual code looks like this:

    <script type="text/javascript">
    top.SetCurrent(self.location);
    window.onload = foo;
    </script>

    I have a frame calling some functions loaded at the top. If I comment
    out the first line the onload line works. This code, though, works (or
    appears to) in MZ and IE6. Is IE5 expecting a 'return true;' from the
    first function call?

    >> whereas this does work:
    >>
    >> <body onload="javascript:foo();">

    >
    > The onload attribute is allready defined to contain script. You don't
    > need to use the javascript pseudoprotocoll here.
    >
    > <body onload="foo();">


    Thanks.

    Andrew Poulos
    Andrew Poulos, Dec 7, 2004
    #3
  4. Andrew Poulos wrote:
    > I've test a few other things and I may having looking in the wrong place
    > for the bug(s). My actual code looks like this:
    >
    > <script type="text/javascript">
    > top.SetCurrent(self.location);


    Do you really want to pass the location object or just the current url
    as a string? I guess you search for:

    top.SetCurrent(self.location.href);


    > I have a frame calling some functions loaded at the top. If I comment
    > out the first line the onload line works. This code, though, works (or
    > appears to) in MZ and IE6. Is IE5 expecting a 'return true;' from the
    > first function call?


    No.

    Daniel
    Daniel Kirsch, Dec 7, 2004
    #4
  5. Daniel Kirsch wrote:
    > Andrew Poulos wrote:
    >
    >> I've test a few other things and I may having looking in the wrong
    >> place for the bug(s). My actual code looks like this:
    >>
    >> <script type="text/javascript">
    >> top.SetCurrent(self.location);

    >
    > Do you really want to pass the location object or just the current url
    > as a string? I guess you search for:
    >
    > top.SetCurrent(self.location.href);


    Thanks, I'll look into using href instead,

    >> I have a frame calling some functions loaded at the top. If I comment
    >> out the first line the onload line works. This code, though, works (or
    >> appears to) in MZ and IE6. Is IE5 expecting a 'return true;' from the
    >> first function call?

    >
    > No.


    I can't really post all the code as there are 100s of lines but how can
    I track down why it's not working just in IE5?

    Andrew Poulos
    Andrew Poulos, Dec 7, 2004
    #5
    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. Boban Dragojlovic

    Dynamic Buttons and Event Handlers, revisited

    Boban Dragojlovic, Jun 24, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,862
    Boban Dragojlovic
    Jun 24, 2003
  2. Trevor Hartman

    Re: crazy event handlers!

    Trevor Hartman, Jun 25, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    960
  3. Oisin Grehan
    Replies:
    3
    Views:
    479
    Natty Gur
    Jul 15, 2003
  4. Robert Millman

    Debug step into event handlers

    Robert Millman, Jul 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    411
    Robert Millman
    Jul 29, 2003
  5. Tom
    Replies:
    0
    Views:
    1,018
Loading...

Share This Page