473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Why don't onerror function alert's popup?

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/
Jul 20 '05 #1
2 6102
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:Wy*****************@news2.news.adelphia.net.. .
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/

Jul 20 '05 #2

"Robert Oschler" <no_replies@fake_email_address.invalid> schreef in bericht
news:Wy*****************@news2.news.adelphia.net.. .
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
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bjarthur | last post by:
i have (see below) what i think is a fairly simple algorithm, but yet it doesn't work. given a directory with consecutively numbered jpeg files (1.jpg, 2.jpg, 3.jpg...), it is designed to count...
3
by: Doug O'Leary | last post by:
Hey; I'm completely new to javascript and am slowly working my way through the O'Reilly's Javascript, the Definitive Guide. One of the examples is supposed to pop up an alert box if there's a...
3
by: Tobius | last post by:
I want to be able to define a custom onerror event that detects an attempt to call a known function and load a file if it's not already loaded and re-call the function. The only problem is that any...
1
by: Jake G | last post by:
I was wondering if anyone could help me with this? I am dynamically loading an image after a user selects an item in a list box. If the image is not available I would like to load a nice error...
1
by: jadeite100 | last post by:
Hi: I am using IE 6 SP2. My resize attribute does not work <body onresize="test1();">. When I resize my window, the resize event doesnot get call. I have a jsp page with an iFrame called...
9
by: Tonio Tanzi | last post by:
I have an asp page with this tag <body onLoad="show_msg('<%=error_msg%>');"> where "show_msg" is a javascript function that shows the message contained in the asp variable "error_msg" only if...
3
by: Jimmy | last post by:
It is also possible for popup window to call function in main window by using the opener property. Will "opener.someFunctionInMain(param1, param2)" in the popup window work? It's possible for...
4
by: josh | last post by:
Hi if I try to attach onerror event via addEventListener window.addEventListener("error", myError, false) it does not work as it pass to myError only the event object but not the three...
5
by: maanand | last post by:
<html> <head> <script type="text/javascript"> onerror=handleErr; var txt=""; function handleErr(msg,url,l) { txt="There was an error on this page.\n\n";
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.