ZDNet UK


Skip to Main Content

ZDNet.co.uk - Winner of Best Business Website 2007
  1. Home
  2. News
  3. Blogs
  4. Reviews
  5. Prices
  6. Resources
  7. Community
  8. My ZDNet

 

ZDNet UK RSS Feeds


IT Jobs

Office applications Toolkit

Writing cross-platform DHTML

Scott Robinson Builder.com

Published: 16 Feb 2003 22:01 GMT

  • Email
  • Trackback
  • Clip Link
  • Print friendly
  • Post Comment

Back in the grand old days of linear programming, one of my IT mentors told me something I've never forgotten: "The easiest code in the world to write is bad code." It was true then; it is even truer in our nonlinear, object-ridden age, when programs are so multifunctional and cross-platformed. We just don't think about it as much because object-oriented programming is, in general, so robust and forgiving of error. It's possible, even easy, to write embarrassingly bad code that runs just fine.

But this is no excuse for sloppy work. (Wait till someone tries to upgrade that sloppy app that "runs just fine.") And the rapid acceleration of Web growth heralds an end to the forgiveness of object code. Web pages themselves must, in these dynamic times, be ridiculously cross-platformed. And therein lies danger for the DHTML programmer.

DHTML coding commandments
You need to avoid a couple of pitfalls when writing for Web applications. First, HTML code, and DHTML code in particular, must function consistently on multiple Web browsers and on multiple versions of those browsers. Second, where compatibility is not possible, a properly written Web app shouldn't crash but should fail gradually, preserving as much function as possible. We're going to look at some coding guidelines to help you meet these goals.

Before we get underway, however, a note of caution: Applying these coding principles can't help but enhance your Web apps, but it's not so easy to actually apply them. They build on one another, so attention to detail is essential, over and above committing to the general principles to begin with. And since the "dynamic" in DHTML covers a number of Web technologies -- scripting, style sheets, and the DOM, to name the big ones -- they must be applied case by case.

The art of browser-sniffing
An essential first step in writing robust DHTML is building browser detection into your code and writing conditional variations on your critical functions so that your pages will have full functionality across a broad spectrum of browsers. It's true that this is a lot easier since more current Web development packages anticipate newer versions of the most prominent browsers. But it's better in the long run if you anticipate a broad audience for your pages, going a little more native and using browser-detection techniques from the earlier days. Your apps are then more certain to work correctly on older systems.

It's tempting to approach a DHTML project with nothing more than the latest Internet Explorer and Netscape Navigator in mind. But the browser world is much broader than this. At last count, more than 200 browsers were in broad deployment, including lesser-used browsers that don't support graphics (Lynx, for example) and browsers that run on operating systems other than Windows and Mac. Hundreds of thousands of copies of earlier releases of Internet Explorer and Netscape Navigator are also still in service, and these may not support all the features that you intend to use in your application.

Next

Previous

1 2


  • Email
  • Trackback
  • Clip Link
  • Print friendly Print with Kyocera

Did you find this article useful?
7 out of 17 people found this useful


Full Talkback thread

0 comments


Company/Topic Alerts

Create a new alert from the list below:











Related Jobs

Internet Team Leader

Working knowledge of server hardware management principles. Working knowledge of general computer networking principles based on IP. Good working ...

J2EE/Java Developer eCommerce, J2EE, JSP, Struts, SQL, UML

Hands-on experience with Unix based systems (Solaris, HPUX, BSD, Linux) including perl and bash scripting. Knowledge of object-relational mapping ...

Senior JAVA Developer-Number 1 eCommerce house- 35,000-40,000 N West

You will ideally bring thorough knowledge of eCommerce principles and must have good HTML skills-hand coding. Full lifecycle experience is needed ...

Featured Talkback

Why do so many (virtually all) software packages think that they are so important that they have to be started automatically every time the computer boots? What is the largest number of "speed access", "update check", "camera download" and whatever other background programs you have ever seen running? Of those, how many did you really need?

By: J.A. Watson

Read full story:
Annoying software: a rogues' gallery

Vista Upgrade Blog

XP survival, from one horses mouth, an...

Hi everyone....for those that need more information on XP survival, I have pasted this open letter from Bill Veghte, senior vice president of microsoft, found on microsoft .com. Hope... More

2 comments

A $40 CONSUMER-class router has create...

Believe it or not I don't work in IT, haven't for 7 years. Yes I work with Microsoft's Windows XP Embedded and as a result I have to know a lot about the OS, the kernal, Win API calls... More

Post a comment

Sick Puppy Redo

I generally follow a dispassionate investigative process when trying to discern what happened when a project goes bad. Although its a low priority item, it gets done simply because... More

Post a comment