// 「Microsoft」の文字列チェック
if (navigator.appName.indexOf("Microsoft") > -1)
document.write("IEです。");
else
document.write("IEではありません。");
// 「Netscape」の文字列チェック
if (navigator.appName.indexOf("Netscape") > -1)
document.write("NNです。");
else
document.write("NNではありません。");
// IEかどうかを変数(isIE)にメモ
var isIE = navigator.appName.indexOf("Microsoft") > -1;
// 変数の内容を表示
document.write("isIE = " + isIE + "<br>");
// if文に使用する
if (isIE) document.write("Internet Explorer です。<br>");
else document.write("Internet Explorer ではありません。<br>");
// NNかどうかを変数(isNN)にメモ
var isNN = navigator.appName.indexOf("Netscape") > -1;
// 変数の内容を表示
document.write("isNN = " + isNN + "<br>");
// if文に使用する
if (isNN) document.write("Netscape Navigator です。<br>");
else document.write("Netscape Navigator ではありません。<br>");