javascript - What should I do if the authorization is rejected when moving to the end of Html5?
天蓬老师
天蓬老师 2017-06-14 10:52:34
0
2
974

When doing positioning, you will be asked for the first time. If your authorization is passed and the positioning is successful, the next time you need positioning, you will not be asked to directly obtain the positioning information.
But if you reject the authorization for the first time, you won’t be able to position it again (because you won’t ask the user, and you won’t be able to use it after you reject it for the first time).

I would like to ask what is the mechanism of this inquiry? Why only ask once? If the positioning is rejected for the first time, it will no longer be used. How to do it?
Code:

function getLocation(){
            if (navigator.geolocation){
                navigator.geolocation.getCurrentPosition(showPosition,showError,{
                });
            }
            else{
                alert("浏览器不支持地理定位。");
            }
        }
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
阿神

A fight with the browser manufacturer may solve the problem.

我想大声告诉你

First, confirm that the browser supports location services, and then still perform location acquisition. If an error is returned, such as error.PERMISSION_DENIED, a prompt will be displayed to inform the browser that positioning is disabled. You can go to the browser settings, clear the website cache, and then try again. Try it, or ask customers to consult the browser manufacturer directly! Please refer to the mobile version of Baidu News webpage!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template