<script type="text/javascript">
<!--
if (window.opera) {
/* Opera の処理 */
}
else if (document.all) {
/* Internet Explorer の処理 */
if (document.fileModifiedDate) { // または window.clipboardData
/* Windows 版の Internet Explorer の処理 */
}
else {
/* Macintosh 版の Internet Explorer の処理 */
}
}
else if (document.layers) {
/* Netscape Communicator の処理 */
}
else if (document.getElementById) {
/* Gecko, WebKit, Blink 系ブラウザ、Internet Explorer 5.0 以降の処理 */
}
else {
/* 上記以外のブラウザの処理 */
}
// -->
</script>
※Windows 版の Internet Explorer を判別する場合、ブラウザにキャッシュをしない場合や CGI による動的なページ等では、document.fileModifiedDate で判別できない場合があります。このような場合は、IE 5.0 以上になりますが window.clipboardData 等を使用して判別してください。なお、document.all は Internet Explorer 9(Internet Explorer 10 の互換表示)までとなります。
window.opera // Opera 12.x まで document.all // Internet Explorer 9(Internet Explorer 10 の互換表示)まで、Opera 9.2x まで document.fileModifiedDate // Internet Explorer 4.0 〜 (Windows) document.layers // Netscape Communicator document.getElementById // Netscape Navigator, Mozilla, Mozilla Firefox, Safari, Google Chrome, Opera, Internet Explorer 5.0 〜
window.external // Internet Explorer 4.0 〜 (Windows) window.clipboardData // Internet Explorer 5.0 〜 (Windows) window.createPopup // Internet Explorer 5.5 〜 Internet Explorer 10 (Windows) IE11 の互換性の変更点
なお、Macintosh 版の Internet Explorer では window.external メソッドは利用できませんが、if (window.external) {...} のようにするとなぜか真 (true) の処理をしますので、ブラウザの判別には使用されない方が良いと思います。(Mac IE 5.14 にて確認済み)
ブラウザのバージョンを調べるにはブラウザの判別を参照してください。