javascripthttp-redirectuser-agentplaystation3

redirect PS3 via user agent


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?


Solution

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