Click to See Complete Forum and Search --> : debugging errors - how?


julchek
12-11-2002, 04:21 PM
I am trying to figure how to debug a script that I have on a page - the actual error tells me the line and character in question, but I do not know exactly how to find the line that is causing the problem - the lines are not numbered, so I am not sure where I should start counting to find the line in question. I am using Dreamweaver 3 to write my code, which I pretty much am handcoding anyway, but I'm not sure how to proceed to debug. Any ideas?

Thanks to anyone who has any ideas for me. I'm pretty new at all this.

MikeOS
12-11-2002, 06:04 PM
In IE you can use the Script Debugger tool. When an error is found it opens the Script Debugger and stops on the line causing the problem (although it isn't always perfect). It comes with loads of features to help you identify bugs. I don't think it comes as part of the standard install, I got mine from Microsoft's Website, and it's free.

In NN browsers you can type javascript: into the browsers address field, then press enter. It opens the Javascript Console, which points out the error. Again, it isn't perfect but it helps, but it doesn't have the features IE's Script Debugger has.

A book I have 'Beginning Javascript from Wrox Press' has a chapter on script debugging. The purpose it to help you identify the problem by explaining the sometimes cryptic error messages thrown up, to be honest once you understand these messages, eliminating bugs is much easier.

Digime
12-11-2002, 08:55 PM
method one:
click ie menus(tools)-->internet option-->advance-->select "show anyOneScriptErrorReport", don't select "show frield http Error"

method two:
<script language="javascript">
function ErrMsg(message, url, line) {
var msg = "";
msg += "A javascript err MessageInfo:\n";
msg += "Error Message: " + message + "\n";
msg += "URL: " + url + "\n";
msg += "Line: " + line + "\n";
alert(msg);
return true;
}
window.onerror = ErrMsg;
</script>