Sitefinity and Mobile

Posted by Community Admin on 04-Aug-2018 21:29

Sitefinity and Mobile

All Replies

Posted by Community Admin on 26-Sep-2013 00:00

Hi--We have a site developed in Sitefinity and several of those pages are specifically for mobile.  I was under the impression that if you typed in one of our url's on a mobile device, the mobile page version would show up.  So for example: if I typed in:  www.hithere.com/training, if we have a mobile page that corresponds with that it would automatically bring up: www.hithere.com/mobile/training.  But its not doing that.  It brings up the full site subpage for a brief instant and then just automatically goes to the mobile homepage.  Any clues?  Thanks!

Posted by Community Admin on 27-Sep-2013 00:00

No one has an answer to this????  This is the javascript that is in the mobile pages:  http://jsfiddle.net/Zmgfp/

Is this what is redirecting every page to the mobile home page?

Posted by Community Admin on 28-Sep-2013 00:00

Hey Belinda,

No the code that takes care of it is this:

<script type="text/javascript">
    var _rdDeviceWidth = (window.innerWidth > 0) ? window.innerWidth : screen.width;
    var _rdDeviceHeight = (window.innerHeight > 0) ? window.innerHeight : screen.height;
    var _rdOrientation = (window.width > window.height) ? 'landscape' : 'portrait';
    if((screen.width > 240) && (screen.width < 320))
        if(!(window.location.toString().toLowerCase().indexOf('http://www.hithere.com/mobile/training') == 0 || window.location.toString().toLowerCase().indexOf('/sitefinity') > 0))
            window.location = 'http://www.hithere.com/mobile/training';
            
    
    if((screen.width > 320) && (screen.width < 480))
        if(!(window.location.toString().toLowerCase().indexOf('http://www.hithere.com/mobile/training') == 0 || window.location.toString().toLowerCase().indexOf('/sitefinity') > 0))
            window.location = 'http://www.hithere.com/mobile/training';
        
 
</script>

(edit: the ruleset might vary ofcourse, this was just a demo ruleset, your pixel values will vary)

The most likely reason why you're seeing your page rendered first is because you've got those scripts you've mentioned in your head tag.

The redirect script inserted by Sitefinity appends to the end of the head, so your scripts get referenced prior to that. Since document.ready won't fire in the head of the page anyway its best to move all JS to the body closing tag.

This thread is closed