« undefined対策 | メイン | sed sed sed »

2007年07月27日

ブラウザごとに振り分け


【対応状況】

document.all … IE4 ~
document.getElementById … IE5 ~、NN6 ~
document.layers … NN4
document.images … IE4 ~、NN3 ~

上記の対応状況を使って、次の例のように細かく振分けることもできます。


■IEのみ
if(document.all){
// IEのみの処理
}

■IE4のみ
if(document.all && !document.getElementById){
// IE4のみの処理
}

■IE5以上のみ
if(document.all && document.getElementById){
// IE5以上のみの処理
}

■NN4のみ
if(document.layers){
// NN4のみの処理
}

■NN6以上のみ
if(!document.all && document.getElementById){
// NN6以上のみの処理
}

■IE4以上とNN6以上のみ
if(document.all || document.getElementById){
// IE5以上とNN6以上のみの処理
}

■IE5以上とNN6以上のみ
if(document.getElementById){
// IE5以上とNN6以上のみの処理
}

■IE4以上とNN3以上のみ
if(document.images){
// IE4以上とNN3以上のみの処理
}

投稿者 muuming : 2007年07月27日 11:56

コメント

コメントしてください




保存しますか?