onerror problem

J

josh

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?
 
S

Stevo

Randy said:
josh said the following on 9/13/2007 7:03 AM:
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.
 
R

RobG

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

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,795
Messages
2,569,644
Members
45,356
Latest member
deepthi.kodakandla

Latest Threads

Top