通过用户代理重定向 PS3 [英] redirect PS3 via user agent
本文介绍了通过用户代理重定向 PS3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望用户在使用 PS3 时被重定向到不同的网页
I want users to be redirected to a different webpage if they are using a PS3
这是我一直在尝试使用的代码
here is the code I have been trying to use
<script language=javascript>
<!--
if ((navigator.userAgent.match(/iMozilla/i)) || (navigator.userAgent.match(/iPLAYSTATION 3/i))) {
location.replace("http://example.com");
}
-->
</script>
可以在此处找到 PS3 的用户代理列表 http://www.useragentstring.com/pages/Playstation%203/
A list of the user agents for the PS3 can be found here http://www.useragentstring.com/pages/Playstation%203/
我似乎无法让它工作,所以我做错了什么?
I cant seem to get it to work so what am I doing wrong?
推荐答案
你可以试试这样的:
<script language=javascript>
var uAgent = navigator.userAgent;
if (uAgent.indexOf("PLAYSTATION") != -1) {
window.location = ("http://example.com");
}
</script>
尝试在服务器端执行此操作可能更容易(下面的 C# 示例)
It may be easier to attempt to do this server side as well (C# ex below)
if (Request.UserAgent.ToUpper().Contains("PLAYSTATION"))
//Send to correct page
Response.Redirect("http://www.example.com/");
}
这篇关于通过用户代理重定向 PS3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文