<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Welcome to nginx!</title>
</head>
<body>
<h2>php $_SERVER['HTTP_USER_AGENT']</h2>
<p>
<?php
echo $_SERVER['HTTP_USER_AGENT'];
?>
</p>
<h2>js navigator.userAgent</h2>
<p>
<script>
document.write(navigator.userAgent);
</script>
<p>
<!--[if lte IE 6]>
<p>lte ie6</p>
<![endif]-->
<!--[if lte IE 7]>
<p>lte ie7</p>
<![endif]-->
<!--[if lte IE 8]>
<p>lte ie8</p>
<![endif]-->
<!--[if lte IE 9]>
<p>lte ie9</p>
<![endif]-->
</body>
</html>
转载于:https://www.cnblogs.com/upshania/p/3898274.html
本文介绍了一种使用PHP和JavaScript来获取浏览器User-Agent字符串的方法。通过PHP的$_SERVER['HTTP_USER_AGENT']和JavaScript的navigator.userAgent属性,可以识别用户的浏览器类型及版本等信息。此外,还展示了如何针对不同版本的Internet Explorer进行条件注释。
2746

被折叠的 条评论
为什么被折叠?



