- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
Cancels ongoing watchPosition call in HTML5
The clearWatch method cancels an ongoing watchPosition call. When canceled, the watchPosition call stops retrieving updates about the current geographic location of the device.
<!DOCTYPE HTML> <html> <head> <script> var watchID; var geoLoc; function showLocation(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; alert("Latitude : " + latitude + " Longitude: " + longitude); } function errorHandler(err) { if(err.code == 1) { alert("Error: Access is denied!"); } else if( err.code == 2) { alert("Error: Position is unavailable!"); } } function getLocationUpdate(){ if(navigator.geolocation){ // timeout at 60000 milliseconds (60 seconds) var options = {timeout:60000}; geoLoc = navigator.geolocation; watchID = geoLoc.watchPosition(showLocation, errorHandler, options); } else{ alert("Sorry, browser does not support geolocation!"); } } function stopWatch(){ geoLoc.clearWatch(watchID); } </script> </head> <body> <form> <input type = "button" onclick = "getLocationUpdate();" value = "Watch Update"/> <input type = "button" onclick = "stopWatch();" value = "Stop Watch"/> </form> </body> </html>
- Related Articles
- How to “enable” HTML5 elements in IE 8 that were inserted by AJAX call?
- Call by value and Call by reference in Java
- IndexedDB in HTML5
- CORS in HTML5
- MediaStream in HTML5
- Difference between Call by Value and Call by Reference
- Subroutine Call Context in Perl
- JavaScript Function Call
- Microdata API in HTML5
- WebSockets Attributes in HTML5
- URL Encoding in HTML5
- DataTransfer object in HTML5
- Conditional call instructions in 8085 Microprocessor
- How to call functions in JavaScript?
- Call a method Asynchronously in C#

Advertisements