Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7309133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:40:49+00:00 2026-05-28T23:40:49+00:00

If a user has disabled the location feature or if he uses a non

  • 0

If a user has disabled the location feature or if he uses a non geo supported feature.

How to do this programatically? This will get executed,if i enable geo location in my browser ,if i do not enable,i want some other code to get executed.Where i put that other code which will be executed when i do not enable or use non supported browser.

<script type="text/javascript">
  var directionDisplay;
  var directionsService = new google.maps.DirectionsService();
  var map;

  function initialize() {
    directionsDisplay = new google.maps.DirectionsRenderer();
    var chicago = new google.maps.LatLng(41.850033, -87.6500523);
    var myOptions = {
      zoom:7,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      center: chicago
    }
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    directionsDisplay.setMap(map);
  }

  function calcRoute() {
    var start = document.getElementById("start").value;
    var end = document.getElementById("end").value;
    var request = {
        origin:start, 
        destination:end,
        travelMode: google.maps.DirectionsTravelMode.DRIVING
    };
    directionsService.route(request, function(response, status) {
      if (status == google.maps.DirectionsStatus.OK) {
        directionsDisplay.setDirections(response);
      }
    });
  }
</script>
</head>
<body onload="initialize()">
<div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T23:40:50+00:00Added an answer on May 28, 2026 at 11:40 pm

    I would use modernizer to sniff out whether the browser supports geolocation and then take the appropriate action.

    if (Modernizr.geolocation) {
      //do geolocation/gmaps stuff
    } else {
      //do something else
    } 
    

    You can even load shims to give the geolocation functionality to browsers which don’t support it. There are examples in the modernizer documentation section.

    e.g.

    Modernizr.load({
      test: Modernizr.geolocation,
      yep : 'geo.js',
      nope: 'geo-polyfill.js'
    });
    

    –Edit

    <html>
    <head>
    <script type="text/javascript"  src="modernizer.js"></script>
    <script type="text/javascript"
      src="http://maps.googleapis.com/maps/api/js?key=&sensor=true"></script>
    <script>
    
    var directionDisplay;
    var directionsService = new google.maps.DirectionsService();
    var map;
    
    function initialize() { 
    
      if (Modernizr.geolocation) {
      // Do the geolocation  
          navigator.geolocation.getCurrentPosition(initializeGeo, handle_error);          
      } else {
      // No geolocation path
      initializeNonGeo();
      } 
    }
    
    function handle_error(err) {
      alert("Geolocation could not be run");
      if (err.code == 1) {
        alert("user denied");// user said no!
      }
      initializeNonGeo();
    }
    
    function initializeGeo() {
      alert("has geolocation");
      directionsDisplay = new google.maps.DirectionsRenderer();
      var chicago = new google.maps.LatLng(41.850033, -87.6500523);
      var myOptions = {
        zoom:7,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        center: chicago
      }
      map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
      directionsDisplay.setMap(map);
    } 
    
    function initializeNonGeo() {
       alert("no geolocation"); //do non geo stuff.
    }
    </script>
    </head>
    <body onload="initialize()">
    <div id="map_canvas" style="width: 500px; height: 300px"></div>
    
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Isn't this a client side control? What will happen if the user has disabled
THIS USER HAS ALREADY ASKED THE EXACT DUPLICATE A FEW MINUTES AGO sql and
If a user has location services on, I assign my RootController as its delegate:
Does a browser download JS files if the user has JS disabled? I'm wondering
I am trying to implement an error message when user has disabled javascript. I
On desktop websites we always think what if the user has JavaScript disabled and
Pretty basic question here. In PHP, if the user's browser has cookies disabled, you
Is there any way possible to detect if a user has disabled JavaScript after
if the user has disabled cookies in the browser, do sessions work? cause i
If a user has cookies disabled in their browser can restful authentication and role

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.