#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    256
    Rep Power
    12

    Redirect script issue


    I'm trying desperately to make a geolocation page and I've been somewhat successful however...I've had to incorporate a script to run to test to see if the user is on a mobile device so that if their privacy settings are on, they are redirected to a certain page. OK...that works. Problem is that now it's redirecting Safari and Chrome, when it shouldn't be...unless of course they're on a mobile device.

    Code:
    if (geoPosition.init()) {
      navigator.geolocation.getCurrentPosition(success, geoError);
    } else {
      alert('Geo Location is not supported');
    }
    function geoError() {
      self.location="anotherpage.html";
    }
    ?
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,910
    Rep Power
    1045
    Hi,

    I don't see any checks for mobile devices in your code. You simply try to get the position, and if it fails (for whatever reason), you do the redirect.

    When running the library in Chrome, I get a PositionError (code 2) saying

    Code:
    Network location provider at 'https://www.googleapis.com/' : Returned error code 404.
    If you check Google, that seems to be a common issue.

IMN logo majestic logo threadwatch logo seochat tools logo