Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript troubleshooting in IE 1

Status
Not open for further replies.

Ghodmode

Programmer
Feb 17, 2004
177
NZ
I use Firefox's JavaScript console extensively. I'd love to have something like that as an add-on of some kind for IE.

I've read about the Microsoft Script Debugger. I've even downloaded and installed something from MS: scd10en.exe.

I don't have the Script Debugger. I have un-checked both "Disable Script Debugging (Internet Explorer)" and "Disable Script Debugging (Other)". I don't have an option that says "Script Debugger" in my View menu.

Double-clicking on the alert icon in the lower left-hand corner of the browser window gives an error message and a line number, but that's nearly useless for a page which is dynamically generated with Perl and sources external JavaScript files.

The page works without JavaScript errors in FF and also passes W3C validation.

Can anyone offer any advice on how to troubleshoot JavaScript code in Internet Explorer?

Thank you,

--
-- Ghodmode
 
Post details on your specific problem - and a link to your page in the Javascript Forum forum216 and you'll get some help.

As for how to do it yourself... I found some useful links to debugging tools in google searching on: Internet Explorer Developer Toolbar

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Thank you for your response.

I'll be able to figure out the JavaScript errors eventually. I've also already posted a few related questions in the JavaScript forum.

For this question, though, I'm really interested in something like the MS Script Debugger. I really meant to post it as a Browser Issue and I'm an IT Professional.

BabyJeffy said:
Post details on your specific problem - and a link to your page in the Javascript Forum forum216 and you'll get some help.

That's just the problem: I can't tell what the specific problem is. The error is [tt]Expected: ';'[/tt], but I'm not missing a semi-colon anywhere. The Web app. I'm working on consists of over 5000 lines. I have narrowed it down to a single js file that I source in, but that's over 400 lines and I don't think people would appreciate a 400+ line posting with a subject line of "why doesn't this work". I'll go through the code myself some more and upload to my Web site before I do that.

It's not currently available on an external Web site, but I'll upload it soon. I'm developing it for an office intranet and it's currently only on my server at home.

BabyJeffy said:
I found some useful links to debugging tools in google searching on: Internet Explorer Developer Toolbar.
Yes [smile] I found the same and I just installed the Web Developer Toolbar and I like it. The DOM inspector is better than the Firefox one. I haven't played with the other features yet, but it doesn't have anything to help with JavaScript debugging [sad]

--
-- Ghodmode
 
At very least, in IE, you can put the word "debugger" in your JS source to forcibly bring up the script debugger so you can step through;

Code:
<script ...>
   ...
   debugger
   ...
</script>

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Update:

I got the MS Script Debugger installed and working (sort of). I just installed it again and it worked. The problem with this is
A debugger break at "JScript - anonymous function" could not be handled because the source document could not be found.
Check the class path in the Debug Options dialog. The application will continue.

Then, everything stops on me and Task Manager reports everything as "Not Responding"... [evil] I'll save my MS rant for another time ...

So, this is still a browser issue: how do I translate IE's debugging alert into something meaningful?

Unless you're Bill Gates, please don't mistake my frustration for a bad attitude. I really appreciate everyone who posts here to help out.

--
-- Ghodmode
 
Thanks, BillyRay. That allowed me to verify that it's the file I thought it was and solved the problem where the debugger couldn't find the file.

Now I think I know where to start putting alert statements :)

--
-- Ghodmode
 
After working through all of my nested frames and Perl that generates JavaScript that generates more Javascript, I found that the problem was some unescaped single-quotes. It's solved now.

And a summary of what I've discovered to answer my original question:
[ul]
[li]IE is terrible for troubleshooting and the MS Script Debugger isn't much of an improvement.[/li]
[li][tt]alert()[/tt] will never be replaced.[/li]
[li]if you are dynamically generating HTML and JavaScript, but can't find the error, do this to the string variable that holds the HTML/JavaScript right before you print it out:
Code:
// if codeStr is the var with the code...
codeStr2 = codeStr.replace(/</g, '&lt;').replace(/>/, '&gt;');
document.write(codeStr);
... then you can copy and paste the code into a text editor (Vim [shadeshappy]) and troubleshoot it directly.[/li]
[/ul]

... Yes, this was a browser issue [neutral]...

--
-- Ghodmode
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top