Joelthezombie15 Posted March 15, 2014 Share Posted March 15, 2014 So im using notepad++ and im trying to get geolocation to work but it wont. This is what i have so far. <p id="demo">Click the button to get your coordinates:</p> <button onclick="getLocation()">Try It</button> <script> var x=document.getElementById("demo"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else{x.innerHTML="Geolocation is not supported by this browser.";} } function showPosition(position) { x.innerHTML="Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude; } </script> It should work. but it wont (Im using chrome) did i mess something up? Link to comment Share on other sites More sharing options...
davej Posted March 15, 2014 Share Posted March 15, 2014 If I'm remembering right this sort of stuff does not work for an HTML file on your desktop. The file has to be on a server. http://www.w3schools.com/html/html5_geolocation.asp 1 Link to comment Share on other sites More sharing options...
Joelthezombie15 Posted March 15, 2014 Author Share Posted March 15, 2014 If I'm remembering right this sort of stuff does not work for an HTML file on your desktop. The file has to be on a server. http://www.w3schools.com/html/html5_geolocation.asp oh that would explain it. Link to comment Share on other sites More sharing options...
ironheartbj18 Posted April 18, 2014 Share Posted April 18, 2014 I am using chrome. why the geolocation wont showing getLocation i checked on my advance setting there is no necessarily checkbox "Send a "Do Not Track" request with your browsing traffic" I am not sure what excalty the file will go through from the document.getElementById("demo"). I checked at http://www.w3schools.com/html/html5_geolocation.asp it does not help me please help me what did i wrong anyone who have experienced this problem before thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now