我有以下 html 来检测用户代理是否来自黑莓设备。我想知道如何将下载 url 替换为特定于设备的 url,即,如果他的设备是 9800,我想指导用户下载 9800 设备。请有人帮忙吗?
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
var ua = navigator.userAgent;
document.write("BB OS Version :: " + ua);
if (ua.indexOf("BlackBerry") >= 0) {
if (ua.indexOf("Version/") >= 0) { // ***User Agent in BlackBerry 6 and BlackBerry 7
Verposition = ua.indexOf("Version/") + 8;
TotLenght = ua.length;
document.write("BB OS Version :: " + ua.substring(Verposition, Verposition + 3));
}
else {// ***User Agent in BlackBerry Device Software 4.2 to 5.0
var SplitUA = ua.split("/");
document.write("BB OS Version :: " + SplitUA[1].substring(0, 3));
}
}
</script>
<br>
<a href="http://mysite.com/download">Download</a>
</body>
</html>