Why don't onerror function alert's popup?

R

Robert Oschler

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/
 
M

ManoDestra

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

Janwillem Borleffs

Robert Oschler said:
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: .....
window.onerror=x;

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

JW
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top