473,509 Members | 2,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onerror problem

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
parameters
error message, url, line number as in: window.onerror = myError
infact if I assing it via window.onerror = myError it works!

any idea?

Sep 13 '07 #1
4 3869
josh said the following on 9/13/2007 7:03 AM:
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
parameters
error message, url, line number as in: window.onerror = myError
infact if I assing it via window.onerror = myError it works!

any idea?
Novel idea: Use window.onerror=myError instead of addEventListener and
all is fine with the world.......

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Sep 13 '07 #2
Randy Webb wrote:
josh said the following on 9/13/2007 7:03 AM:
>infact if I assing it via window.onerror = myError it works!
Novel idea: Use window.onerror=myError instead of addEventListener and
all is fine with the world.......
All is fine with the world as long as nothing else was already assigned
as the handler. If it was, then it's nuked.
Sep 13 '07 #3
Stevo said the following on 9/13/2007 10:08 AM:
Randy Webb wrote:
>josh said the following on 9/13/2007 7:03 AM:
>>infact if I assing it via window.onerror = myError it works!
Novel idea: Use window.onerror=myError instead of addEventListener and
all is fine with the world.......

All is fine with the world as long as nothing else was already assigned
as the handler. If it was, then it's nuked.
If it was, and you add another that handles the errors a different way
or is written to specific errors, then one of them is nuked anyway.
Adding onload events when one already exists is one scenario where I can
see it mattering, but with onerror it just seems perverse to want more
than one function handling them.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Sep 14 '07 #4
On Sep 13, 9:03 pm, josh <xdevel1...@gmail.comwrote:
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
parameters
error message, url, line number as in: window.onerror = myError
infact if I assing it via window.onerror = myError it works!

any idea?
You can try the following (works in IE and Firefox at least):

function addWindowOnerror(fn) {
var oFn;
if (typeof window.onerror == 'function') {
oFn = window.onerror;
window.onerror = function(a, b, c){
oFn(a, b, c);
fn(a, b, c);
}
} else {
window.onerror = fn;
}
}
--
Rob

Sep 14 '07 #5

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

Similar topics

2
6107
by: Robert Oschler | last post by:
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...
4
8926
by: Jürgen Heyn | last post by:
Good afternoon, I am handing a string as a parameter pImage = "Images/Available.jpg" If this image is NOT available I would like to load Images/NoImage.jpg. Unfortunately the following code...
1
6143
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...
2
4116
by: Tee | last post by:
what's the differences between "Overrides Sub OnError" and "Sub Page_Error" ?
3
2224
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...
2
13727
by: crazydave | last post by:
Hi, I've been using window.onerror to capture and report JavaScript errors from other users for debugging an application I've written. But I've run into a strange issue with Firefox and...
5
2911
by: Pete Verdon | last post by:
I'm working on a fairly sizeable javascript application. I recently added some error-handling to it, using window.onerror to catch them. This sometimes works and sometimes doesn't; if I introduce a...
5
1540
by: test9991014 | last post by:
Hi, I gather that Javascript standard function names are case sensitive and they follow the old Smalltalk manner of applying case e.g. thisName, however I am curious, I see "onerror" mentioned...
0
7412
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...
1
7069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4730
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
441
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.