HTML and CSS Reference
In-Depth Information
Mobile browsers, including Mobile Safari and Opera Mobile,
prompt the user with a modal dialog each time a call is made
to the API, stopping all code execution until the user responds
(
Figure 9.3
). Mobile browsers like Firefox Mobile and WebKit
on Android do not block the page from running, but still clearly
prompt the user for a response.
FIguRE 9.3
Mobile Safari with
a modal dialog, blocking the
app from continuing.
The geolocation API exists inside the
navigator
object and
contains only three methods:
•
getCurrentPosition
•
watchPosition
•
clearWatch
The
watchPosition
and
clearWatch
are paired methods. They work
the same way as
setInterval
, and
setTimeout
.
watchPosition
returns a unique identifier, that can be later cancelled by passing
the value to
clearWatch
.