![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How does mobile safari determine when to prompt the user to share location in HTML?
When we have a requirement in which we want to track the latest locations for a user only when they are in a certain area, then we write separate code for it. The code to determine when to prompt the user to share location in HTML is as follows -
if (frstTime) { //First time navigator.getCurrentPosition(function (coordinates) { if (coordsAreInTheBox) { storeCoordsForUser(); navigator.watchPosition(); } }); } else if (userInlocat) { navigator.watchPosition(); }
It works as expected on the first load. It will check for whether the user came for the first time; if yes, then the navigator gets the current position. After that, according to coordinates in the box, we watch positions. If the user is in location then watch position.
Advertisements