ブラウザを判定して表示する JavaScript のサンプルです。
この記事の目次 非表示
実際に動作するサンプル
https://codepen.io/darucub/pen/gbrLPaN
サンプルコード
<HTML>
<HEAD>
<META HTTP-EQUIV="content-type" CONTENT="text/html;charset=x-sjis">
<TITLE>Your Browsers</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
//determines which stylesheet to write based on
//browser/platform combination. Also sets global
//variable bp for browser/platform testing elsewhere.
if (navigator.platform.indexOf('Mac') > -1) {
//mac
if (navigator.appName.indexOf('Microsoft') > -1) {
//explorer
document.write('mac_ie');
} else {
//netscape
document.write('mac_nn');
}
} else {
//windows or unix
if (navigator.appName.indexOf('Microsoft') > -1) {
//explorer
document.write('win_ie');
} else {
//netscape
document.write('win_nn');
}
}
// -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#ffffff">
</BODY>
</HTML>
現場からは以上です。それでは、またッ!!!
