Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript JS Redirection to Mobile causing an issue

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #145216
    owlinargyle
    Participant

    A week or so ago, I was looking for a solution to redirect our users from our classic site to our mobile site if they were on a mobile device. I found a JS on Github, that appeared to work perfectly – see the thread.

    My Codepen

    I had originally tested the script using the following devices LG Optimus G with Android 4.1, iPhone4 with most recent version OS, iPad with an unknown OS version, and a Samsung Galaxy Note2 with unknown OS version. They had all worked perfectly with in our internal network and without.

    But now, a week later, I’m getting reports that some of our users on our internal wireless network are getting stuck in an endless “loading loop”, where it never actually redirects to the mobile site.

    So far we’ve noted the following devices iPad with the most recent version OS, a Samsung Galaxy S1 running Android 2.3 and a Motorola Xoom running Android 4.1. All are using the browsers that came with their OS.

    I’m concerned that these specific devices (their OS or their user agents) are not included in the script.

    I’m totally new to this mobile stuff and I’m hardly a JS guru. (I’m mainly a designer!) So I’m having a hard time interpreting the code that I think is defining this information. Line 102?

    I could use some insight, if anyone has the time. Thanks!

    #145219
    Alen
    Participant

    Line 102 is Regular Expression from http://detectmobilebrowsers.com make sure you keep the two in sync. Thing with User-Agent sniffing is that you have to keep this up-to-date.

    You should also probably submit issue here: https://github.com/sebarmeli/JS-Redirection-Mobile-Site so that developers can take a look.

    #145277
    owlinargyle
    Participant

    @Alen I had noted that the http://detectmobilebrowsers.com link was referenced in the code and checked it, but all I saw was the message that “No mobile browser detected.`Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)”, which is obviously my desktop browser info. I didn’t think about clicking on the buttons to get scripts. Told you I’m new at this. Doh!

    I updated the user-agents, and that seems to have stopped the endless loading loops, but now the redirection has completely stopped for all devices as well. =(

    I did go and submit the issue on Github. Thanks

    #146043
    owlinargyle
    Participant

    The author has still not responded, but no matter.

    I figured out the issue with why the redirection had stopped. When I had updated the user-agents, it changed a reference of “agent” to “a” in two places. So my script had to have those same references updated as well.

    Those changes were added on lines 54 (55) and 133 (134) on my CodePen.

    I also discovered that if tablet_redirection parameter is defined as “false” then the tablet_host parameter is not necessary and that is what was causing the infinite loading loop on some devices.

    Problem solved. =)

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.