Connecting Tech Pros Worldwide Help | Site Map

Why don't onerror function alert's popup?

  #1  
Old July 20th, 2005, 10:13 AM
Robert Oschler
Guest
 
Posts: n/a
If I set window.onerror to an error handler I've created, I don't see the
browser error dialogs anymore but I don't see the alert() messages in my
error handler pop up either. Can someone tell me what I am doing wrong?
Here's the test doc I'm using:

=========== BEGIN TEST DOC ===================

<HTML>
<TITLE> OnError Test </TITLE>
<HEAD>

<script>
window.onerror=x;

function x(a, b, c)
{
alert("hello");
alert(a + b + c);
return true;
}
</script>

</HEAD>
<BODY>
<script>
bbb(); // Function doesn't exist so it triggers error.
</script>
</BODY>
</HTML>

========== END TEST DOC ==========

--

Robert Oschler
"Let the web hear you, add your voice to your web site in minutes!"
-- http://audiodirect.spiderchase.com/
(For a limited time, free voiceover with every sign-up, use this link
instead)
-- http://audio.spiderchase.com/
(A song - are you blue?)
-- http://bluedreams.spiderchase.com/


  #2  
Old July 20th, 2005, 10:13 AM
ManoDestra
Guest
 
Posts: n/a

re: Why don't onerror function alert's popup?


Your code worked fine in my browser. I can't see anything wrong with what
you've written. It is correct to say "window.onerror = x" not
"window.onerror = x(1, 2, 3)" as you are merely registering the function
that will handle the error, it will take the three parameters that are
normally passed to the standard onerror anyway. If you are not seeing the
correct info or alerts, I would suggest that it is a browser problem.

I tried to do something similar at work recently on IE5 and it didn't work,
even though window.onerror is part of JavaScript 1.2. Didn't work at all.
Tried it at home and IE6 and it works beautifully. If you're running IE6,
then I have no idea why this is not working for you.

Peter.

"Robert Oschler" <no_replies@fake_email_address.invalid> wrote in message
news:WynSa.605$gi.763359@news2.news.adelphia.net.. .[color=blue]
> If I set window.onerror to an error handler I've created, I don't see the
> browser error dialogs anymore but I don't see the alert() messages in my
> error handler pop up either. Can someone tell me what I am doing wrong?
> Here's the test doc I'm using:
>
> =========== BEGIN TEST DOC ===================
>
> <HTML>
> <TITLE> OnError Test </TITLE>
> <HEAD>
>
> <script>
> window.onerror=x;
>
> function x(a, b, c)
> {
> alert("hello");
> alert(a + b + c);
> return true;
> }
> </script>
>
> </HEAD>
> <BODY>
> <script>
> bbb(); // Function doesn't exist so it triggers error.
> </script>
> </BODY>
> </HTML>
>
> ========== END TEST DOC ==========
>
> --
>
> Robert Oschler
> "Let the web hear you, add your voice to your web site in minutes!"
> -- http://audiodirect.spiderchase.com/
> (For a limited time, free voiceover with every sign-up, use this link
> instead)
> -- http://audio.spiderchase.com/
> (A song - are you blue?)
> -- http://bluedreams.spiderchase.com/
>
>[/color]


  #3  
Old July 20th, 2005, 10:13 AM
Janwillem Borleffs
Guest
 
Posts: n/a

re: Why don't onerror function alert's popup?



"Robert Oschler" <no_replies@fake_email_address.invalid> schreef in bericht
news:WynSa.605$gi.763359@news2.news.adelphia.net.. .[color=blue]
> If I set window.onerror to an error handler I've created, I don't see the
> browser error dialogs anymore but I don't see the alert() messages in my
> error handler pop up either. Can someone tell me what I am doing wrong?
> Here's the test doc I'm using:[/color]
.....[color=blue]
> window.onerror=x;
>[/color]

window.onerror = function () {
x('a', 'b', 'c');
}

JW


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript not working on my PC but ok on others drwyness answers 16 August 22nd, 2008 12:04 AM