您可以試試navigator.userAgent api來獲取瀏覽器信息。
<html lang="en">
<head>
<meta charset="UTF-8">
// for ie < 11
<script type="text/javascript">
if(/MSIE \d/.test(navigator.userAgent))
alert("Will only work in IE below IE11")
</script>
</head>
<body>
以上10
<html lang="en">
<head>
<meta charset="UTF-8">
// for ie < 11
<script type="text/javascript">
if(/Trident.*rv:/.test(navigator.userAgent))
alert("Will work for IE11")
</script>
</head>
<body>
在IE瀏覽器控制檯運行navigator.userAgent
您可能會看到這一點取決於即版本
"Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; rv:11.0) like Gecko"
Trident.*rv
是從輸出取這可能會改變api
來源
2017-12-03 06:43:26
brk
感謝您的答覆,但問題沒有解決! – Manish