spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / javascript / sniffing / 2 current pageTo page 2
[next]

Web Project Manager
Aquent
US-PA-Collegeville

Justtechjobs.com Post A Job | Post A Resume
Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

Object Sniffing New Browsers, Part 2: Other Browsers

In the first article we looked at how utilizing the information a browser sends to your Web server using the user-agent string is problematic, and you could use object detection in order to distinguish between three recent browsers based on the khtml rendering engine, namely: Konqueror, Safari and OmniWeb. We now go one step further by looking at how you can use JavaScript object detection in order to properly distinguish between recent versions of the Netscape browsers.

Why go through the bother of having to identify the browser viewing your site? If you know the type of browsers that hit your Web site, you can better craft your Cascading Style Sheet (CSS) and JavaScript code to take full advantage of the properties and functions that the browser is capable of, and at the same time avoiding known bugs and unsupported properties.

Son of Mozilla

There is little doubt that Netscape 6 was a great improvement over the previous 4.x release, containing far greater standards support for such things like CSS, XML and RDF, along with a much more robust JavaScript architecture. For a long time, the 4.x release of Netscape was the bane of many Web developers, many finding it the lowest common denominator of Web design, especially when Internet Explorer 5.x and 6.0 became dominant. A lot of people sighed a collective sigh of relief when Netscape 6 came out for all the new features it supported, so there were (and are) good reasons to detect this browser in order to take advantage of the features it has to offer.

While not the same quantum leap as its predecessor, Netscape 7 builds upon the developments of version 6, including new and much improved support for things as SOAP, XSLT and access to Web Services via JavaScript. If you're looking to take advantage of any of these features, these are good reasons to want to tell the difference between these two browsers.

The two most recent versions of Netscape are based upon the Gecko rendering engine, first developed for the Mozilla browser, and this fact makes it easy to distinguish both from the version 4.x versions of Netscape. In order to detect the presence of this rendering engine, you just have to look for a match for where navigator.product, as in the following code snippet:

var is_nn6up (navigator.product == 'Gecko')?true:false;

If this statement is true, you are looking at either Netscape 6, 7 or Mozilla.

To tell the differences between them, you need at how the Gecko engine differs between Netscape 6 and 7. Netscape 6 was based upon the Mozilla 0.9 build, and includes a reduced version of the Gecko rendering engine. Netscape 7 was based upon the full Gecko rendering engine available to Mozilla 1.x builds.

In order to tell the difference between Netscape 6 and 7, you can look for the presence or absence of the window.find method, which is used to search the contents of a window for a given string. It is not present in Netscape 6, but is in Netscape 7, so the following two lines will yield different results based on the version of Netscape used:

var is_nn6 (navigator.product == 'Gecko' && !window.find)?true:false;

var is_nn7 (navigator.product == 'Gecko' && window.find)?true:false;


home / programming / javascript / sniffing / 2 current pageTo page 2
[next]

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Symantec Whitepaper: Converging System and Data Protection for Complete Disaster Recovery
Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
  Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Symantec Whitepaper: Comprehensive Backup and Recovery of VMware Virtual Infrastructure
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Fixing MySQL Replication · Firewall Guide: First Steps to Securing the Enterprise · VoxOx Tames the Tumultuous Communications Tangle

Created: March 27, 2003
Revised: August 12, 2003

URL: http://webreference.com/programming/javascript/sniffing/2