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.
i've been doing the javascript work for years now. without a debugger it's been the most frustrating thing possible. also, since much of the work I do also involves back-end scripting in PHP, it becomes difficult tracking down the line of offending javascript since the line numbers in my editor don't match up with what's rendered in the browser (yes, i know, i could view script, but this just slows the process down)
the best way i found is to use the alert() javascript function for variable inspection.
on the other hand, it's probably best to avoid javascript as much as possible, even for form validation. it's not worth the headache from a programmatic point of view.
Paul K.
How about this Othello game or this game of noughts and crosses.
While it is mildly interesting to watch this food fight over proper approaches, languages to use etc. the discussion here appears to miss the point.
Web programming lacks decent debugging tools.
In my experience, we had browser hosted software, but it was targetted toward an intranet so we could specify the software that needed to be installed on both the clients and the servers. As the product became more complex and more developers were brought on, debugging became a nightmare.
Although less technical minds felt that the product should be a "pure web solution", we began implementing a number of server side COM objects in C++ because we COULD debug them. Explaining them to new developers on the project became easier, too.
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.
Next, you should never rely on JavaScript to do your form validation
You should never rely on it, but you should always have it (if supported by the browser). Web pages that use only round trips for validation are horrible and often incomprehensible. It's just plain bad interface, and the alternative is simple, easy, and produces a far better result.
User clicks submit. You alert "You need to enter the donation amount" and set the focus to the appropriate field.
If you think it would be better to let the submit happen, and return the page with an error at the top saying "Amount not entered - you must enter something in all the red fields!", you're silly. By the way, I've seen exactly that on a web page - apparently their hatred for employing available browser technology meant they couldn't even set the focus to the missing field.
Let's not stir that bag of worms...
There are lots of DHTML debuggers out there. Of course alert() is always handy, but having an actual debugger available really helps out.
Visual Studio came with Visual InterDev, which does a passable job with debugging. Even with its flaws, it has saved me a lot of time over the years.
Nobody needs a true debugger. Heck, nobody needs CVS. Nobody really needs profiling. Nobody needs a relational database.
I think, though, that the best programmers will take the time to "sharpen the saw" and become proficient in using all these tools. If you're programming without a debugger, you're not working as efficiently as you could. And yet half the replies here suggest the poster is asking for something unreasonable or unavailable. Bizarre.
Let's not stir that bag of worms...
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!
Web Developper Extension.
I can't be the only web developer who tends to have more than one window open at once, can I?
:-)
When you open the debugger, you're in trouble. The second you close it, all other IE windows close. _Very_ annoying and means it gets turned off on all developer boxes here.
(Hmm, must play more with Venkman and the DOM inspector to get more ammo for Moz with colleagues
Greg
(Inside a nuclear plant)
Aaaarrrggh! Run! The canary has mutated!
...and the best solution I've found is to let it keep running until you're ready to have it "help out" by "crashing closed every Explorer window it can find".
It's got some other wierd things going on and has some trouble debugging some stuff, but it's still useful enough that I keep it around.
I suppose its usefulness would correlate pretty well with the size of the largest script you run. For most people creating public-oriented web pages, the largest script they write is going to be pretty small - and a debugger is going to be something they pull out rarely. I end up writing some fairly long scripts at times, and I find it's often worth whatever hassles it presents.
In any case, I too might have to try out some of the alternatives listed in the comments.
Let's not stir that bag of worms...
Sorry to break this to you, but there is a good web debugger. ASP.NET has a great debugging tool (Visual Studio .NET). There are probably others too. Of course, they only debug the server-side stuff, but all is not lost.
.NET with JavaScript validation, without every writing a line of JavaScript code. This is because of specialized web controls that contain pre-debugged JavaScript, customized for the particular browser agent. Anyone can create these controls - I myself have not though, because I am not interested in doing the low-down technical details. I can buy something for less money than it will cost my employer to pay me to build it.
I can write forms in
Even when not using ASP.NET, I have almost never written any JavaScript from scratch. Why do it, when I can spend a few minutes browsing and find a script that does what I want? So, my advice would be to take a step back and consider not re-inventing the wheel unless you have to. Or unless it is your job to manufacture wheels.
Most writers regard truth as their most valuable possession, and therefore are most economical in its use - Mark Twain
Yes, I would be surprised. Do you have any statistics to back this up? And as for bad browsers on the Mac, what the fuck are you talking about? IE5, Safari, OmniWeb, and Mozilla (and derivatives) are all on the Mac and are all very standards compliant. OS X supports more browsers than any other platform.
By the way, you've clearly missed the whole point on standards compliant web development. If you build a web site with standards, its degredation (if necessary) will be graceful. For example, if I write pages using XHTML, everything from screen-readers to Lynx to Netscape 4 to the latest version of WhizbangBrowser will be able to use and navigate the content. That is most definitely not the case with other "solutions".
If we use DHTML and JavaScript on the other hand, everyone except those with WhizbangBrowser are locked out of the content. I think what you meant to say was: "For those of you that suggested just using DHTML and JavaScript.. 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 Windows is just a nightmare."
Please get a clue.
Join Tor today!
Jerk City Troll, you are so abrasive. There really are much better ways to make your point. It's so unpleasant to read anything you post.
Understated, DHTML is difficult. However, in my experience, if you adhere to XHTML and can get your code to work in Mac IE5 and Netscape 4.7 then it will work in %99.9 of the browsers out there (not %100 because I havn't tried them all).
People often slam Netscape 4.7, but truth be told it is an excellent yard stick to measure your code against. The reason why is because it fails on bad code instead of trying to compensate for it. It DOES support DHTML, but the the support is lacking. However, despite the lack of support you can still do many nice things with it. I have.
I'm also surprised that in a discussion of DHTML no one has linked to Quirksmode, which is extremely useful.
Go to Debug menu, click Show DOM tree.
I assume other browsers have equivalents.
I've had this sig for three days.
Yes, you are correct that I fucked that up. I was in a rush. Awesome site btw, I love the design and the code. Little by little, well-built as well as well-designed sites are popping up. A couple years ago, you saw none of that.
Join Tor today!
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!
OS X may support more browsers than any other platform, but how many average Mac users are going to hunt them down? Also, considering how popular the Apple/Mac duo is in education, and how many school districts--at least here in the midwest--are having funding problems and would hire the cheapest, inexperienced system administrators they could find, most Mac users are going to be on whatever is installed by default. So, if the default browser is standards compliant and capable, they're good to go. Otherwise, they're pretty much screwed.
Trying to debug anything on MacIE or Safari is a real pain in the ass. Neither will even bother to tell you when you have a syntax error -- the javascript will simply stop at some random point.
Despite what you say about standards compliance, the W3C DOM implementation is basically shit on both MacIE and it's replacement Safari. (Both do OK with CSS.) It's like Netscape 4 standards -- sure it's "supported", but it doesn't work.
> For those of you that suggested just using DHTML and JavaScript.. that tends not to be an option in the real world
The "real world", at least for vertical apps, is "rich interfaces" on Internet Explorer for Windows. Generally if you do it correctly, these apps will run just fine on Mozilla and sometimes on Safari. Nobody pays for simplistic XHTML that degrades gracefully.
Here is what I have had problems with.
DIV -> they lay them out close but when you get into needing pixel precision, I have had problems. Try laying out 2 div's next to each other and adding borders 1px wide and use absolute layout. Set widths and heights and then view in both. arg!
IE has a bug when opening new windows. Session is gone, and so are your cookies. You have to basically do a get for IE passing the session and any cookies or info you need. Arg IE sucks if you use new windows.
Mozilla does not deal with the object tag the same as IE especially if you are dealing with word documents. Mozilla needs a plugin IE embeds the control for you without the plugin.
Crossbrowser DHTML can be a real chore, but it depends on what you need to do.
Mozilla and Firebird come with the JavaScript Console, which shows you ALL the errors when the page loads or the script gets executed, I have not seen this in IE, not to this extent. This is basically ALL I use for my DHTML.
For more info on what is going on I use the http headers plugin for Mozilla / firebird to see what cookies are being sent and what is going on. Then I have to go and debug it to get it working in IE. Once you have it working in both IE and mozilla it usually works in Opera and Safari and Konqueror.
Only 'flamers' flame!
Does slashdot hate my posts?
I tend to like things in tables with a good table browser and have a relational language to query them. I wish the DOM model was turned into a relational equivalent. It would require a lite-duty relational engine and perhaps "dynamic" columns rather than the pre-declared staticly-typed kinds often found these days. IMO it is easier to grok and query (study) information if it follows relational normalization rules. Wishful thinking? Perhaps. Non-relational structures have generally proven difficult to query over the years, and when they grow past a certain complexity it starts to show. They found this out in the 60's when early databases were trees, associative arrays, and pointers.
Table-ized A.I.
I code DHTML on a daily basis. I use the MS Script debugger(free). I also use myEclipse plugin for the Eclipse IDE. If you use Tomcat5 you can debug/animate JSP pages which is handy in many cases. Also as in a previous post alert() is your friend!
--freak
That's easily avoided. Before you close the debugger, go to the Debug menu and select "Detach All".
Detaching the debugger from a process leaves the process running. Stopping the debugger generally stops the process it's attached to. That's why when you close the debugger window, it asks if you want to stop debugging. Why it doesn't give you the option right there to detach all and then close is a mystery to me, since that's almost always what I want.
you hit on a point that is more true than you think... School Districts here in the midwest have been hit hard over the last 5 years, and most have moved to WinTEL platforms for their computers... even 7 years ago when I graduated high school, there wasn't a mac in the building, and when I came to college, I found most of my fellow classmates had the same type of environment.
Any more, the schools that can afford the macs are doing so because they have a sys admin that wants macs around, and usually they're very experienced in handling macs
(p.s. I highly doubt OS X "supports the most browsers of any platform"... there are so many prototype browsers developed by educational institutions [2 created here last year alone], just because macs have two browsers that won't run on any other platform doesn't mean they have the most... windows has a lot of the same types of browsers!!!)
>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!
At least 75% of the scripts I find at all the popular Javascript sights are ridiculously heavy for what they do - they also tend to be enormously slow (check out the DHTML menus at mta.info for an example). They rarely degrade gracefully, instead spending hundreds of lines of browser detection and browser specific behavior. Stock scripts like the kind you're advocating have probably cause me more pain in my web programming career than anything else.
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.
If everybody coded according to the standards, there would be nothing on the internet worth seeing, since most browsers don't follow the standard. I like standards as much as the next guy, but software is a business, and people write websites to solve problems and satisfy customers/users. If your website is standards compliant, but not usable by your target market, your fanaticism costs you your customer.
Web developers can't just close their eyes and say "I will only follow standards!" To think so is naive.
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!
It's a bit of a catch-22, isn't it? If I write standards-compliant code, and no browsers support my standard, then my site is useless. If enough sites are useless, customers will complain that they can't reach the sites they want. But meanwhile, my site is useless and thus I don't get paid. So I write a site that works, even if it's not standards compliant, and then nobody complains, so browsers don't need to support the standard.
The key is that a standard is only as good as the implementations of it. Even if the NEXT version if IE or Moz or Konq is so great that it supports all standards you care about, there are still going to be so many people who are unable to use that next version of the browser. So they use an older one, that still works. So, if I care about those people, I have to support them. That's how things work; that's why computer systems get crufty. And that's why people use HTML tables for positioning, or javascript when they should use CSS (or vice-versa).
If you cared about the people, you'd inconvenience them temporarily by using standards-compliant code only. Hacking to suit the browsers will inconvenience a significant group of people perpetually.
Don't get me wrong, I understand the socio-economical factors here; I'm just saying that long-term, this would be a better choice.
Marxist evolution is just N generations away!
It enumerates all the javascript objects it can find by using a call like "for i in x". I eventually got it opening in the search pane with a treeview that allows you to examine every value of every field you can find starting with window.opener.
Not sure if it will work in Mozilla, and it does need to be loaded from the same site.
Code available on request.
09F91102 no, 455FE104 nope, F190A1E8 uh-uh, 7A5F8A09 that's not it, C87294CE no. Ah! 452F6E403CDF10714E41DFAA257D313F.
The script debugger was already mentioned. but If you go into the IE 5.x downloads section and get the Microsoft Web Developer Accessories, it gives you some handy utilities. I know it says 5.x, but I've used these just fine in 6.xx. The "DOM tree" has a few issues, but can be handy for tracking down how to reference an object. View Partial Source, I find, saves me a ton of time, particularly when I am checking the generated HTML from a mixture of HTML/JSP code. I just highlight the HTML item I want to see the source for and right-click and choose "view partial source".. No more searching through the HTML source to see if I set the property right or my JSP is hosed.
DO NOT DISTURB THE SE
Eight millionth post. Informative or not, truly a historic slashdot moment.
sulli
RTFJ.
Hi, I have at my site here a javascript for flashing the title "Inge's Homepage" in colors yellow and red. But, unfortunatelly, this script does not work. Can You please help me?