5-4 请老师检查
来源:5-4 编程练习
慕妹6205103
2020-06-18 16:50:36
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>userAgent</title>
</head>
<body>
<input type="button" value="点击获取浏览器信息" id="browser">
<script type="text/javascript">
function getBrowser () {
var explorer = navigator.userAgent.toLowerCase(),browser;
if (explorer.indexOf("msie") > -1) {
browser = "IE";
} else if (explorer.indexOf("firefox") > -1) {
browser = "Firefox";
}else if (explorer.indexOf("chrome") > -1) {
browser = "Chrome";
}
return browser;
}
document.getElementById('browser').onclick = function () {
var result = getBrowser();
alert("您使用的浏览器是" + result + "浏览器")
}
</script>
</body>
</html>
1回答
好帮手慕星星
2020-06-18
同学你好,代码判断没有问题,很棒。继续加油,祝学习愉快!