Galloway
Galloway

Reputation: 13

Redirect from Sharepoint Site to Mobile Site Not Functioning for Android Users

I'm working with a SharePoint site in which the pages display poorly in mobile, so much so that it's essentially nonfunctional. I'll be rebuilding the site to solve those issues, but in the meantime, I'd like to redirect mobile users to a dedicated mobile site that's built outside of SharePoint. The problem is that my redirects are working fine for iPhones and not working for Android OS.

I've tried the following in the master page:

<script type="text/javascript">
if (screen.width <= 699) {
if (document.referrer.indexOf('http://site.html') == -1){
document.location = "http://site.html";
}}
</script>

and

<script type="text/javascript">
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)){
if(document.URL !="http://site.html")
 {
    window.location ="http://site.html";
  }
}
</script>

AND

   <script type="text/javascript"> // <![CDATA[
    if ( (navigator.userAgent.indexOf('Android') != -1) ) {
        document.location = "http://SITE.html";
    } // ]]>
</script>

I understand that Android users need to manually enable JavaScript, so I assume that's probably the issue. Any recommendations for alternatives?

Thanks.

Upvotes: 1

Views: 381

Answers (1)

Niels V
Niels V

Reputation: 995

When no javascript is available on Android, you need to move the redirect logic to the server. You have multiple options there (building your own HTTP Module, User Control or WebPart for SharePoint). One solution which runs without development skills is using the IIS Rewrite Module (http://www.iis.net/downloads/microsoft/url-rewrite). You can configure it on user agent, see for instance IIS 7.5 URL Rewrite rule to handle request based on user agent.

Upvotes: 1

Related Questions