Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
48
rated 0 times [  54] [ 6]  / answers: 1 / hits: 64793  / 12 Years ago, mon, july 30, 2012, 12:00:00

I have an issue with window.navigator, I'm getting error code 1, User denied Geolocation whenever I run the following code as a local html file:



navigator.geolocation.getCurrentPosition(function(position) {
console.log(position);
}, function(positionError) {
console.log(positionError);
});


The output is coming from the error function, positionError contains:



code: 1
message: User denied Geolocation


This does not happen if the containing html is served from some server.



Is this expected? Is there some way to use navigator from a local html? I am trying to write some mobile app, but am also trying to avoid network whenever possible.



thanks.


More From » html

 Answers
30

If you are using chrome, please have a look at the answer below:



HTML 5 Geo Location Prompt in Chrome



It appears this is a security restriction for the file protocol. Looks like you are going to need to host it locally from a server.


[#83980] Saturday, July 28, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
isham

Total Points: 69
Total Questions: 86
Total Answers: 86

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
;