Git Product home page Git Product logo

js-redirection-mobile-site's People

Contributors

dcheck avatar jacksaidwhat avatar jwitko avatar prabaharancs avatar sebarmeli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

js-redirection-mobile-site's Issues

tablet_host parameter not working when not equal to mobile_url & continuous redirect to my tablet_host

Please add the Microsoft Surface (that no one is going to buy) with for the agent = "Mozilla/4.0 (Compatible; msie 7.0; windows nt 6.2; arm; trident/6.0; touch; .net4.0e; .net4.0c; tablet PC 2.0; Version)"; // Microsoft surface.

We should be safe to add "tablet" in the agent match pattern.

I was getting a continuous redirect to my tablet_host, because you where checking the referrer to only the mobile_host. The fix was move the isUATablet test before setting the cookies/session and the change the test to
(isUAMobile && document.referrer.indexOf(mobile_host) >= 0 )
|| (isUATablet && document.referrer.indexOf(tablet_host) >= 0) || ....

Oh .. your setting either the session OR cookie variable. So the final test for the redirection should be "&& !isCookieSet && !isSessionStorage" not !(isCookieSet || isSessionStorage).

William Choy
NorthPoint Solutions

PS: Here is the patch (Sorry for the funky formatting):

Index: js/redirection-mobile.js

105a106,113

// Check if the device is a Tablet such as iPad, Samsung Tab, Motorola Xoom, Amazon Kindle or MS Surface
if (!!(agent.match(/(iPad|SCH-I800|xoom|NOOK|silk|kindle|GT-P7510|tablet)/i))) {

  // Check if the redirection needs to happen for tablets
  isUATablet = (config.tablet_redirection === TRUE || !!config.tablet_host) ? true : false;
  isUAMobile = false;

}

109c117

< if (document.referrer.indexOf(mobile_host) >= 0 || queryValue === FALSE ) {

if ((isUAMobile && document.referrer.indexOf(mobile_host) >= 0 ) || (isUATablet && document.referrer.indexOf(tablet_host) >= 0) || queryValue === FALSE ) {
129,136d136
< // Check if the device is a Tablet such as iPad, Samsung Tab, Motorola Xoom or Amazon Kindle
< if (!!(agent.match(/(iPad|SCH-I800|xoom|NOOK|silk|kindle|GT-P7510)/i))) {
<
< // Check if the redirection needs to happen for tablets
< isUATablet = (config.tablet_redirection === TRUE || !!config.tablet_host) ? true : false;
< isUAMobile = false;
< }
<
138c138

< if ((isUATablet || isUAMobile) && !(isCookieSet || isSessionStorage)) {

if ((isUATablet || isUAMobile) && !isCookieSet && !isSessionStorage) {

Android Razr Maxx

Noticed with the update last week to Android 4.0.4 that the script is not working on the noredirection call. It will redirect to the mobile site fine but not allow the override to the full site work.

Set the position of the URL prefix for mobile site

At the moment the prefix ("m" default one) is prepended to the url, I'd like to define the position of the "prefix", so it could be possible something like redirecting "en.domain.com" to "en.m.domain.com".

Endless Loading loop, Updated User-Agents and redirection stopped

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 your JS and it appeared to work perfectly for my needs.

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 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 was concerned that the user-agents weren't set up correctly. (I’m totally new to this mobile stuff and I’m hardly a JS guru. I’m mainly a designer!) But I was having a hard time interpreting the code that I think is defining this information. Line 102? A fellow developer recommended keeping my User-Agent Sniffing up to date using the site - http://detectmobilebrowsers.com that is noted in the script. So I did that.

This is a demo of how I set it up:
http://codepen.io/downcasteyes/pen/rztne

Now the endless loading loops have ceased, but so has all redirections on all devices we've tested. How would updating the user-agents affect the redirection like that? Is there something else in my version of the code that I need to look at?

redirection-mobile-self javascript error

There seems to be a typo on line 93 of: redirection-mobile-self

One of the regex's tests .test(a) instead of .test(agent), causing a javascript error and execution to halt, therefor not redirecting.

Error when cookies disabled

When cookies are disabled in Chrome, session storage also disabled in such a way that it throws an exception when access is attempted. This terminates the script, and prevents redirection of mobile browsers.

Uncaught SecurityError: Failed to read the 'sessionStorage' property from 'Window': Access is denied for this document.

on_before_redirect

Great you picked this up but there is one problem,

I only need to redirect my script if the callback returns true. otherwise my callback is not able to prevent redirecting.

does not work for ios5 devices

Hi there,

the redirection works great for i.e. ios 4 but on my devices (4s, 3gs) with ios5 it doesn't.
any ideas? :-)

best
stefan

Ipad Redirect

With respect to this Script:

<script> SA.redirection_mobile ({ mobile_url : "whatever.com/example", mobile_prefix : "https" }); </script>

Where must the tablet redirect line be placed, thus far its inclusion depending on placement has either not worked, or in the worst case caused it to stop redirecting mobile phones as well.

Is there a way in the Redirection-Mobile.JS code to change the default to redirect tablets as well? (I am fairly new to javascript)

Thanks

Overide Redirect

Is there any way to force a mobile device that would normally be redirected to be allowed to see the normal landing page.

What i want is to be able to have a link back to standard view after a user is redirected like many websites do at the moment.

Example Error: Var name typo error

Hi,

I copy pasted the below code from example and found that tablet redirect not working.
SA.redirection_mobile ({
mobile_url : "mobile.whatever.com",
tablet_url : "tablet.whatever.com",
});

Finally I found that, you have mentioned var "tablet_host" as "tablet_url". So please correctthat typo error in the examples section. Now its working fine, thanks for the plugin.

Failed test

Hello, i download the zip file and uploaded the test folder for test. I have alot of error like, Died on test #1 Cant find variable SA

Script has stopped working in some android devices

Hey, wonderfully easy script. We deployed it to several pages on a plone-based cms site recently and it worked fine on a number of devices when we first tested, but for some reason we are finding that some android devices are failing to execute the script. We've had it fail on several droids and a newer samsung infuse, but it works fine when using firefox's user-agent switch and setting the UA to the various flavors of android. One tester claims that the site did redirect correctly several months ago, but that it now fails. This would make me think the problem was with the the device dealing with cookies/storage, but the samsung infuse we tested on had never visited the site before. It continues to work fine in IOS devices so I'm guessing something in the expression that test for android?

I also found this site with a big Regex test for devices, maybe useful for yours as well? http://detectmobilebrowsers.com/

Our Site: library.unt.edu.

Thanks for your hard work!

"redireciton" should be "redirection"

It is in the introduction,

<script src="redireciton-mobile.js"></script>

It wast me five miniuts to find out what's wrong with the code,please correct it before others wast their time.

Galaxy Tab 10"

The tablet_redirection: true does not work for Samsung Galaxy Tab 10". I changed android 0.5 to android and it works but I wonder if I broke something else on other devices. FYI, the UA for this device is shown in my logs as:

Mozilla/5.0 (Linux; U; Android 3.2; en-us; GT-P7510 Build/HTJ85B) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/5

so I suppose other than android, we have GT-P7510 as a potential for defining the device.

Great script!

redirecting HTTPS:// to HTTP://

Hi, I am calling the js on the page header, giving it a if is_front_page so that it will only get redirected from the website's homepage. However, I am trying to tackle the fact that my website is SSL secured (https://) and my mobile website is not (http://m.).
At the current code the http prefix (or https) is matched. Can you point out where this can be specified?

I am calling the code like this, in my wordpress head:

<?php wp_head(); ?>
<?php if ( is_front_page()  ) { ?><script type="text/javascript" src="https://piccolo.co.il/js/redirection-mobile.js"></script><script type="text/javascript">// <![CDATA[
 SA.redirection_mobile ({
 mobile_url : "m.piccolo.co.il",
 });
 
// ]]></script>';}<?php } ?>

Many thanks

Take iPad off the list of browsers..?

Hi, I would like to allow the iPad to go to the noraml version of the site instead of being redirected to the mobile version, is there an option/code a can change to make this happen..?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.