Seeking Good DHTML Debuggers?
christodd queries: "After years of programming in PHP and C++, I've finally delved into the world of Javascript and DHTML. The biggest hurdle I have come up against is the various web browser DOMs. I find that I spend much time googling for variable names, and guessing which variables do what. My favorite tool is a good debugger, and this is where I'm having problems. There is a commercial product by Netscript due out this quarter for $190.00, and there is a very young open source project at BiteSizeInc, but I have yet to find anything production quality. How does everyone else debug browser DOM issues?"
Mozilla and Firebird come whith a Javascript debugger, and it works.
I'm from Argentina: Tango, Asado, Mate, Gaucho, Maradona, YPF
The Mozilla Document Object Model Inspector is very useful. It comes with Mozilla and Firebird.
http://www.mozilla.org/projects/inspector/
In addition to the Venkman JS debugger mentioned in a previous comment, Mozilla and Mozilla Firebird also include an excellent DOM inspector - very handy for page tweaking, "DHTML" or not.
My advice to you, is dont use Javascript , DHTML unless it is really neccesary. Its good for image rollovers and validating forms but the moment you try and do anything fancy with it like manipulating layers you will be plagued by crossbrowser incompatibilities.Generally speaking most of the dynamic content driven things can be done with your existing PHP / backend code.
I have been developing websites for a number of years, and when I do have problems i have usually found that by typing "javascript:" into the offending browser (after an error has occurred) and / or stepping through the code and evalutating variables using the javascript command
alert(insert_problem_variable);
has been able to help me debug frustrating problems most every time. I really dont think you need to fork out hundreds of dollars for a debugger when you just need to use your nonce and a copy of the best javascript book ever written
Electronic Music Made Using Linux http://soundcloud.com/polyp
Javascript and DHTML are the worst technologies I know of.
Stick with HTML/XHTML and CSS. You have PHP, what more could you possibly want? It's better to create web content that is accessible by everyone, than to produce fancy schmancy stuff that only a few people can access, and even fewer will appreciate. I hate Javascript and all other "dynamic" happenings in my browser. Focus on your content.
Craig
... there still is hope. Venkman won't run in IE, but you can get something like Venkman:
To debug Javascript in Internet Explorer with more than just a few alert() statements, you need to install the MS Script debugger. It has two versions, one for NT/2000/XP and one for 9x/ME. There is even a KB entry describing how to find the Debugger in the jungle of microsoft.com: KBID 268445.
Just my 2 cents.
Tux2000
Denken hilft.
alert() *is* pretty handy for JS debugging, but these bookmarklets make it even more...um... handier.
Since you didn't mention it, everyone should at least let you know it exists: MS Visual Interdev has a script debugger.
It isn't a magically good debugger (like some MS debuggers really are) but it works OK. It also benefits from integration with IE (ie, when Explorer encounters a script error, it can sometimes jump right to the debugger).
It also does the IntelliSense thing (to an extent) allowing you to reference styles and objects without remembering their (often silly) names.
Let's not stir that bag of worms...
I've spent several years writing various bits of functionality in JavaScript for clients. It is the worst platform to code for I've seen in some time.
I've tried some of the debuggers, and found them to not be very useful at all.
Sadly, you can't beat 'doing it the old way' using either alerts (useful as they're blocking) or setting up a debug layer (div) to output your debug content to.
It sounds more like you're looking for a reference than anything else. I'd highly recommend the DHTML Definitive Reference. It covers everything, along with good structural tips, like creating a platform independent DHTML API.
For those of you that suggested just using XHTML and CSS.. that tends not to be an option in the real world. You would be amazed at how many Companies use version 4 browsers. And anything on the Mac is just a nightmare.
Hope this helps.
I would recommend diving into the world of Mozilla. They offer a couple of awesome tools for Javascript and DOM debugging. Check out the following: Venkman Javascript Debugger DOM Inspector Mozilla Firebird Specifically with Firebird, after you have it installed, go check out some of the available extensions at texurizer.net/firebird/extensions and download some of the cool extensions like the 'Web Developers Toolbar'. These pieces of software have proved invaluable to my productivity! I have used them to debug javascript, XUL and everything in between. Good luck!
This comes from years of pent-up frustration from working with people who don't understand why this stuff is important. What's worse is reading people making suggestions to learners that will no doubt perpetuate bad web development practices. It's often been a difficult up-hill battle where people refuse to even try the standards-compliant, structural-markup approach. Nevertheless, I've proven the virtues of standards-compliance time after time again.
Most recently, my company was slating a lot of time to make an alternate theme and printer-friendly pages for a web application. I convinced them to let me redo the site in XHTML and I was able to deliver any theme they wanted in less than half a day creating new stylesheets. With benefits like these, I just cringe at other approaches.
But yes, I need to learn to be less pissy. :) (Sorry to everyone who I've spit venom at today.)
Join Tor today!
>Technologies like JavaScript + CSS (=DHTML) are STANDARDS - they are created to use in web browsers. I use them wherever I need to, and code for MSIE and NS6+ (with a focis on the latest Mozilla release).
Interesting contradiction.
I say: do not find out what browser does what; find out what the respective standards say, and code according to that. Someone's browser will display it wrong, but that's mitigated by including the following disclaimer: "Your browser does not fully support the existing website standards, and you may suffer problems on other sites as well. You may continue to viewing the site, or you can download a standard browser here."
If more webdevs understood that, we wouldn't even have to have this discussion.
.
Marxist evolution is just N generations away!
Not to mention that XHTML isn't some magic potion that'll make your site work properly. CSS and stylesheets are great for that sort of thing, but the various cross browser issues force all sorts of hackery that reminds me a great deal of the stupid crap we did to work around bugs in table rendering in the 90s (@import to "hide" from old browsers? Bah). At the sites that oh-so-helpfully explain these tricks sound so proud, as they talk about the advantages of web standards.
Yes, I know that using tables for layout is evil. Of course, theres a variety of layouts that CSS is simply incapable of, and the cross-platfrom CSS you need to properly implement even some relatively simple layouts is far larger than the comparable table code, and it'll work (not even degrade to simple text, but actually WORK) on non-CSS compliant browsers, and it'll render faster (and often in a more user-friendly manner) than the CSS...
I use CSS alot for effects and styling. It's really handy for some layout stuff (like a static menu). It's makes a great addition to a table based layout, where you used to have to play games with single pixel cells and whatnot. But it's a nightmare for overall layout. Call me when CSS 3 is finalized and has at least 80% support in all major browsers.
One of the things that saved my sanity when doing a DHTML UI was creating a log window that I could write messages, the contents of JS variables, DOM objects, etc. to. It isn't as good as a real debugger, but it helped out quite a bit. I created a JS class that supported two methods:
// etc
log = new Log();
log.log("blah");
log.dump(someObject);
The first method just prints out the specified message, the second recursively prints all of the attributes an object, since in JS they are really just hashes that you can traverse automatically with a for in in x loop. At least in IE, this let me inspect form elements, etc. as if they were native JS things. The log class could technically be a singleton, but since each instance writes to the same window, it really doesn't matter. I just instantiate a new Log object at the top of each document, and can then enable/disable it at will by typing a javascript:log.enable() command in the address bar.
function Log() {
}
Log.prototype.enabled = false;
Log.prototype.enable = function() {
this.enabled = true;
this.logWindow = window.open("", "Log", "width=80,height=25,resizable,scrollbars=yes");
this.logWindow.document.open("text/plain");
this.logWindow.blur();
}
Log.prototype.disable = function() {
this.enabled = false;
this.logWindow.close();
}
Log.prototype.log = function(msg) {
if (this.enabled) {
this.logWindow.document.writeln(msg);
}
}
Log.prototype.dump = function() {
if (this.enabled) {
}
}
This is detailed in the O'Reilly Rhino Javascript book, which is an excellent resource for JS programming and DHTML.
The inference was that if everyone wrote standards-compliant code, then the BROWSERS WOULD HAVE TO DISPLAY IT! Better sites and less buggy browsers. Geez.
Marxist evolution is just N generations away!