DOMのdocument要素によるブラウザ識別

1.IE4以上、およびNN3以上のチェック

document.imagesは、IE4.0以上、およびNN3.0以上であることを識別するために使用できます。
if (document.images)  document.write("IE4.0以上、あるいはNN3.0以上のブラウザです。";
else  document.write("IE3以下、またはNN2以下のブラウザです。");
実行結果:



2.IE5以上、およびNN6以上のチェック

document.getElementByIdは、IE5.0X以上、およびNN6.0以上であることを識別するために使用できます。
if (document.getElementById)  document.write("IE5.0以上、あるいはNN6.0以上のブラウザです。";
else  document.write("IE4.X以下、またはNN4.X以下のブラウザです。");
実行結果:



3.IE4以上のチェック

document.allは、IE4.0X以上であることのチェックに使用できます。
if (document.all)  document.write("IE4以上のブラウザです。");
else  document.write("IE3以下、またはIE以外のブラウザです。");
実行結果:



4.NN4のチェック

document.layersは、NN4であることのチェックに使用できます。
if (document.layers)  document.write("NN4です。");
else  document.write("NN4以外のブラウザです。");
実行結果:



5.IE5以上のチェック

document.allとdocument.getElementByIdで、IE5以上であることのチェックに使用できます。
if (document.all && document.getElementById)  document.write("IE5以上のブラウザです。");
else  document.write("IE4以下のブラウザです。");
実行結果:



4.NN6以上のチェック

document.allの否定とdocument.getElementByIdで、NN6以上であることのチェックに使用できます。
if (!document.all && document.getElementById)  document.write("NN6以上のブラウザです。");
else  document.write("NN6以上のブラウザではありません。");
実行結果:



メイン画面に戻る