Connecting Tech Pros Worldwide Forums | Help | Site Map

event handlers in IE5

Andrew Poulos
Guest
 
Posts: n/a
#1: Jul 23 '05
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

Daniel Kirsch
Guest
 
Posts: n/a
#2: Jul 23 '05

re: event handlers in IE5


Andrew Poulos wrote:[color=blue]
> 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>[/color]

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).

[color=blue]
> whereas this does work:
>
> <body onload="javascript:foo();">[/color]

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

<body onload="foo();">

Daniel
Andrew Poulos
Guest
 
Posts: n/a
#3: Jul 23 '05

re: event handlers in IE5


Daniel Kirsch wrote:
[color=blue]
> Andrew Poulos wrote:
>[color=green]
>> 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>[/color]
>
> 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).[/color]

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?
[color=blue][color=green]
>> whereas this does work:
>>
>> <body onload="javascript:foo();">[/color]
>
> The onload attribute is allready defined to contain script. You don't
> need to use the javascript pseudoprotocoll here.
>
> <body onload="foo();">[/color]

Thanks.

Andrew Poulos
Daniel Kirsch
Guest
 
Posts: n/a
#4: Jul 23 '05

re: event handlers in IE5


Andrew Poulos wrote:[color=blue]
> 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);[/color]

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);

[color=blue]
> 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?[/color]

No.

Daniel
Andrew Poulos
Guest
 
Posts: n/a
#5: Jul 23 '05

re: event handlers in IE5


Daniel Kirsch wrote:[color=blue]
> Andrew Poulos wrote:
>[color=green]
>> 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);[/color]
>
> 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);[/color]

Thanks, I'll look into using href instead,
[color=blue][color=green]
>> 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?[/color]
>
> No.[/color]

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
Closed Thread