我是JS新手,每當有人通過Interent Explorer瀏覽器進入我的網站時,我需要檢測它。所以,我做了下面的代碼,我創建的div正在其他Web瀏覽器上編寫腳本,我認爲問題出在.getElementById之類。 所以說話後,下面的代碼:JS中非常基本的東西
<html>
<head>
<script type="text/javascript">
var browserName=navigator.appName;
if (browserName=="Microsoft Internet Explorer")
{
document.getElementById("example");
}
</script>
</head>
<body>
<div id ="example">You're Using Interent Explorer. </div>
</body>
</html>
非常感謝的助手。
你沒有對你正在尋找的元素做任何事......這個函數的意圖是什麼?更重要的是,你爲什麼要檢測IE?這可以用HTML註釋,即'' – Fosco