in reply to What is your Javascript-workflow?

Hi,

I am writing web applications since several years now and I am used to the problem. There is no efficient was to debug JavaScript code. In my opinion the tips here are all valid. But as usual the solution is a mix between all suggestion.

Differentiate the scripts needing input from the PERL program and the other. Pack the script scripts which do not rely on PERL variables in libraries in a separate directory and include them at the start of the form:

print CGI::start_html( ... -script=>[ {-type=>'JAVASCRIPT', -src=>'../js/utils.js'}, ] ), "\n";

or

print '<script type="text/javascript" src="../js/utils .js"></script>',"\n";

If your script relies on PERL output you have to place it in the code. Example:

print qq~ <script type="text/javascript"> function Whatsoever() { myElement = window.document.getElementById.... … return true; } </script> ~;

Notice: if you write a multi language application most of your JavaScript will have to be included in the PERL code.

To debug the scripts I use Firefox and Firebug. It has an integrated console that is very useful remains open! Selenium is definitely what you want to test your forms. Easy to learn and to use.

The JavaScript debugging process is clumsy anyway. The alert() statement is very useful at this point in time.... If you designed your forms properly, meaning you thought about what is happening as the user reloads a form it resumes to:

If you did not thought about the reload issue... I recommend you start thinking.

K

The best medicine against depression is a cold beer!