[英]javascript user agent redirect by browser version number
We have a chat program that works with only a couple of browsers right now.我们有一个聊天程序,现在只能在几个浏览器上运行。 So, I'm inserting a user agent redirect to manage the messaging to inform the user why they can't chat with their unsupported browser.
因此,我插入了一个用户代理重定向来管理消息传递,以通知用户为什么他们无法与不受支持的浏览器聊天。
The issue I'm having is only Firefox 3.1 and under, for example, is supported for FireFox., but my custom script below is enabling all Firefox versions compatible.我遇到的问题仅是 Firefox 3.1 及以下版本,例如,FireFox 支持。但我下面的自定义脚本使所有 Firefox 版本兼容。 What's the solution to have only Firefox 3.1 be compatible?
只有 Firefox 3.1 兼容的解决方案是什么?
Note: I don't plan to send them to the actual browser websites as seen in my example.注意:我不打算将它们发送到我的示例中看到的实际浏览器网站。 I just put those URLs in for example purposes only.
我只是将这些 URL 放入示例中。 I plan to have custom redirect pages with friendly messaging on them...
我计划在自定义重定向页面上添加友好的消息...
Demo of existing code: http://jsfiddle.net/evanmoore/4xr77/现有代码演示: http://jsfiddle.net/evanmoore/4xr77/
Code is below:代码如下:
<script type="text/javascript">
if ((navigator.userAgent.indexOf('Firefox') != -1) || (navigator.userAgent.indexOf('MSIE') != -1))
{
// Your browser is supported for live chat
document.location = "http://www.livechatinc.com/";
}
else if(navigator.userAgent.indexOf("Safari") != -1)
{
// Your Safari browser is not supported for live chat
window.location = "http://www.apple.com";
}
else if(navigator.userAgent.indexOf("Chrome") != -1)
{
// Your Chrome browser is not supported for live chat
window.location = "http://www.google.com/chrome";
}
else
{ // All others... Your browser is not supported for live chat
window.location = "http://www.gofetch.com";
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.