Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-31-2004, 10:01 PM   PM User | #1
Basscyst
Smokes a Lot


 
Join Date: Jul 2003
Location: CA, USA
Posts: 1,594
Thanks: 5
Thanked 20 Times in 20 Posts
Basscyst is on a distinguished road
Enable script errors in IE

My work seems to have locked me out of the advanced tab in IE, so I can't enable script errors. Every now and again it will still prompt me with an error and I can click the checkbox to always provide notification. I can't for the life of me though, figure out what I am doing for it to throw the error, it seems random. If anyone knows or if they know of another way to enable the error reporting it'd be swell.

Basscyst
__________________
Helping to build a bigger box. - Adam Matthews
Basscyst is offline   Reply With Quote
Old 10-31-2004, 10:20 PM   PM User | #2
liorean
The thread killer


 
Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
liorean will become famous soon enoughliorean will become famous soon enough
Well, there are a number of practical things. If it's an iew specific error, your best shot is probably to use the Microsoft Script Debugger.

Another solution that only works for cross browser errors is to use the excellent debuging facilities of moz. JavaScript Console, enabling strict warnings, using Venkman (the JavaScript Debugger), the DOM inspector and the error tracing features in the native objects provide the best platform for bug tracking you can find.

Op7, if you enable displaying errors in the JavaScript Console, is excellent for tracing errors related to events and event handling, though it in other areas is not quite as good as the moz JavaScript Console. Op7 has the benefit of being closer to iew than moz is, when it comes to host environment.

Then there are the source code tricks you can use. The most efficient is to insert try..catch statements in the code, and alerting/prompting values for inspection to follow the runtime environment. There are of course cruder things you can use as well.

(Hmm, I kinda recall posting about JavaScript debugging this in the FAQ some time back, maybe you should check there.)
__________________
liorean <[lio@wg]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
liorean is offline   Reply With Quote
Old 11-01-2004, 07:50 AM   PM User | #3
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Question

"There are of course cruder things you can use as well."

More details, please!
Philip M is offline   Reply With Quote
Old 11-01-2004, 06:11 PM   PM User | #4
liorean
The thread killer


 
Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
liorean will become famous soon enoughliorean will become famous soon enough
Well, how about using the address bar for inserting 'javascript:' pseudo URIs for inspecting the runtime, using the window.onerror event, or just filling your script with alerts, confirms and prompts? Neither is as useful as the detect-and-handle approach of try..catch and well placed inspection if-statements for the non-error bug detection. Onerrror doesn't allow locally specific handling in the way try..catch do. etc.

I listed the tricks I think are most useful.
__________________
liorean <[lio@wg]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
liorean is offline   Reply With Quote
Old 11-01-2004, 11:50 PM   PM User | #5
Basscyst
Smokes a Lot


 
Join Date: Jul 2003
Location: CA, USA
Posts: 1,594
Thanks: 5
Thanked 20 Times in 20 Posts
Basscyst is on a distinguished road
Indeed, I see where you are coming from, and appreciate the advice but I can't install any additional software. With all due respect I wasn't asking about the best ways to debug a script or alternativesto IE, I was asking what I can due in my code to throw the error in IE even if the script errors are off, so that I can turn it back on by clicking the always display the errors checkbox. Somtimes if I just throw in a random quote mark or somthing it will pop up anyhow. If noone knows that's cool. I can muddle through.

Basscyst
__________________
Helping to build a bigger box. - Adam Matthews

Last edited by Basscyst; 11-01-2004 at 11:57 PM..
Basscyst is offline   Reply With Quote
Old 11-02-2004, 03:51 PM   PM User | #6
Roy Sinclair
Senior Coder

 
Join Date: Jun 2002
Location: Wichita
Posts: 3,880
Thanks: 0
Thanked 0 Times in 0 Posts
Roy Sinclair will become famous soon enough
Noting your inability to alter the working environment, as Liorean pointed out the most efficient way to catch errors is using the try { ... normal code here ...} catch (errorInformation) {... error handling code here...} construct. If you wrap an entire function in a try block then any errors in that function will be passed to the catch block. The variable "errorInformation" is the error object and you can display the error using an alert.

Code:
function flaky()
     {
      try
           {
            // Some code that may generate errors
            }
       catch (theError)
            {
             alert(theError.message) 
             }
       }
__________________
Check out the Forum Search. It's the short path to getting great results from this forum.
Roy Sinclair is offline   Reply With Quote
Old 11-04-2004, 07:47 PM   PM User | #7
Basscyst
Smokes a Lot


 
Join Date: Jul 2003
Location: CA, USA
Posts: 1,594
Thanks: 5
Thanked 20 Times in 20 Posts
Basscyst is on a distinguished road
Thanks Roy, I see how it works. That helps a bit, I usually use an alert to narrow down the area the error is occuring. At least now I can see why the error is occuring. Still more time consuming then just having it tell me what line the error is on (or around at least, IE error reporting does still suck). I really just needed the example, I understand now.

Thanks,
Basscyst
__________________
Helping to build a bigger box. - Adam Matthews
Basscyst is offline   Reply With Quote
Old 11-04-2004, 09:49 PM   PM User | #8
kansel
Regular Coder

 
Join Date: Jul 2002
Location: Kansas, USA
Posts: 465
Thanks: 0
Thanked 45 Times in 44 Posts
kansel is on a distinguished road
Of course there's the obvious. If the script you are working on is for work, you should inform your supervisor or IT dept. that the "standard practices" are keeping you from efficiently completing your job. Given the highly technical aspect of your job, they should at least consider turning on IE's script error dialog for your installation so that you can continue writing quality scripts.
kansel is offline   Reply With Quote
Old 11-04-2004, 10:15 PM   PM User | #9
Roy Sinclair
Senior Coder

 
Join Date: Jun 2002
Location: Wichita
Posts: 3,880
Thanks: 0
Thanked 0 Times in 0 Posts
Roy Sinclair will become famous soon enough
Quote:
Originally Posted by kansel
Of course there's the obvious. If the script you are working on is for work, you should inform your supervisor or IT dept. that the "standard practices" are keeping you from efficiently completing your job. Given the highly technical aspect of your job, they should at least consider turning on IE's script error dialog for your installation so that you can continue writing quality scripts.
If they're half as head-blind as the people in charge of security where I work he's got next to no chance of making that happen. One size never fits all but you can't convince some people of that.
__________________
Check out the Forum Search. It's the short path to getting great results from this forum.
Roy Sinclair is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:19 PM.


Advertisement
Log in to turn off these ads.