Browser Filtering

3.0, 2007-07-20
Scripting Methods
Stylesheet Methods
HTML Methods

Using the user agent string to determine the capabilities of the client platform is difficult and unreliable. User agent strings follow no predictable standard, change frequently, and can be easily faked.

Filtering may be performed at many layers, see Scripting Methods, Stylesheet Methods, and HTML Methods.

Your user agent string is:


Blocking browsers will alienate some of your audience. Given the state of browser technology, there is no longer a need to create sites or features that do not work with all browsers. Knowing what software is used to access your site can help you look for specific limitations, but should never be used to "slam the door" on your guests.


The layout engine or rendering engine is the part of the browser responsible for displaying web pages on the screen. The layout engine is more important than the brand name or even the operating system because it is what determines what limitations the browser has.

Example 1.1. Layout Engine Detection Script

<script type="text/jscript">
/*@cc_on @if(@_win32) document.write('Trident');
@else document.write('Tasman'); @end @*/
<script type="application/x-javascript">
if(document.layers) document.write('Netscape4');
else if(window.navigator.vendor=='KDE') document.write('KHTML');
else if(window.navigator.vendor=='Apple Computer, Inc.') document.write('WebCore');
else if(window.opera) document.write('Presto');
else if(window.ScriptEngine && (window.ScriptEngine()=='InScript')) document.write('Cab');
else if(!document.all) document.write('Gecko');
else document.write('unknown');

For your browser:


This particular script will not work with true XHTML code, where calls to document.write are not supported.

Common Layout Engines


iCab's layout engine.


Used by Mozilla, Firefox/Firebird/Phoenix, Camino/Chimera, Galeon, Epiphany, K-Meleon, AOL for Mac OS X, CompuServe, Netscape 6+, Skipstone, Salamander, and others.


Used by Konqueror.


Opera's layout engine.


The engine meant for the abandoned Netscape 5. The name of the engine used by Netscape 4 is unknown (Craptor?).


Used by the now-unsupported Internet Explorer for Macintosh.


The incomplete engine used by Internet Explorer for Windows.


An layout engine based on KHTML, used by Safari.


A framework that includes WebCore, for layout, and JavaScriptCore (based on KJS), for scripting.