redirect PS3 via user agent

青春壹個敷衍的年華 提交于 2019-12-31 07:41:28

问题


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>

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?


回答1:


You could try something like this:

<script language=javascript>
    var uAgent = navigator.userAgent;
   if (uAgent.indexOf("PLAYSTATION") != -1) {
      window.location = ("http://example.com");
   }
</script>

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/");
  }


来源:https://stackoverflow.com/questions/6779631/redirect-ps3-via-user-agent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!