Challenge : File permission for a javascript file | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Challenge : File permission for a javascript file

Run the file only when the user permits it. eg : location, camera etc

13th Oct 2017, 2:52 AM
Ashwani Kumar
Ashwani Kumar - avatar
1 Answer
+ 3
Use prompt for this purpose // The code, not the exact locn = prompt('This site wants to access your location'); if(locn == true){ geolocation.getCurrentPosition(); } // Output: This site wants to access your location OK(true) CANCEL(false) // OK and CANCEL are buttons
14th Nov 2017, 6:27 AM
#RahulVerma
#RahulVerma - avatar