473,382 Members | 1,464 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,382 software developers and data experts.

self.onerror help?

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 javascript error. I
typed in the code pretty much as documented but it didn't work. In
an attempt to troubleshoot, I simplified the thing but it's still
not working. The html and javascript code is posted below. Can
someone tell me what I screwed up?

I've hit the page with Opera 7.54, IE 6 and Netscape 7.0. Same results
in all three. I get the message between the <h1> tags but not the
alert window. All popup blockers have been turned off as well.

Thanks for any help.

Doug O'Leary

<html>
<body>
<script>
var error_count = 0;
var email = "dkoleary";

// Create the error handler function
function report_error(msg, url, line)
{ alert("You attempted bad!");
return true;
}
self.onerror = report_error;
</script>

<h1>Display something!</h1>
<hr>

<script>
alert(no_such_variable);
</script>
</body></html>
Jul 23 '05 #1
3 4872
Lee
Doug O'Leary said:

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 javascript error. I
typed in the code pretty much as documented but it didn't work. In
an attempt to troubleshoot, I simplified the thing but it's still
not working. The html and javascript code is posted below. Can
someone tell me what I screwed up? self.onerror = report_error;


Try:

window.onerror = report_error;

works in IE 6 and Firefox 1.0.1

Jul 23 '05 #2
On 2005-03-03, Lee <RE**************@cox.net> wrote:

Try:

window.onerror = report_error;

works in IE 6 and Firefox 1.0.1


Thanks. That got it working in IE & netscape, but not opera. According
to the book, self is supposed to be a synonym to the window property.
Guess it's not implemented in whatever version of javascript is running
in the various browsers that I have.

Thanks for the tip; I appreciate it.

Doug O'Leary

Jul 23 '05 #3
Doug O'Leary <dk******@olearycomputers.com> spoke thus:
Thanks. That got it working in IE & netscape, but not opera. According
to the book, self is supposed to be a synonym to the window property.
Guess it's not implemented in whatever version of javascript is running
in the various browsers that I have. Thanks for the tip; I appreciate it.


If it makes you feel any better, I have the same book and experienced
the same frustration with making this particular example work,
although I still believe it's a fine book overall.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #4

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

Similar topics

2
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...
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...
2
by: Tee | last post by:
what's the differences between "Overrides Sub OnError" and "Sub Page_Error" ?
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...
0
by: JR | last post by:
I am opening a html page using showModalDialog. To the page's onError event, i am attaching custom event handler. When ever any exception occures, onError event is firing 2 times. I found the same...
2
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
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...
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.