Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > PHP/MySQL/Scripting

  • Print
  • + Share This
From the author of

A slick way to deal with the browser version problem

The bane of the HTML author (not to mention the JavaScript author) is making sure that the pages you create will work as intended on older browsers (or at least they won't look really horrible). One way to handle this problem would be to write code that checks for specific older browsers. You could write code that loops repeatedly and says to the browser "Are you Netscape 2? Are you Netscape 3? How about Internet Explorer 2.0?" and so on, stopping when it gets a positive answer. Trouble is, there are so many browser versions out there now that it's becoming difficult to make code like this work, especially as it becomes obsolete every time some company releases a new browser version.

Script 2 deals with this problem by checking document.images, which in effect says "Does the browser understand image objects?"

The trick here is that document.images is only implemented in JavaScript 1.1 and later, which was released with Netscape 3.0, and therefore eliminates a whole class of older browsers in one swoop.

  • + Share This
  • 🔖 Save To Your Account