navigator.geolocation.getCurrentPosition always fail in chrome and firefox

后端 未结 7 804
予麋鹿
予麋鹿 2020-12-16 02:04

I got strange behavior when I tried to test my \"navigator.geolocation.getCurrentPosition\" web page. Here is my testing result and code:

my code:

fu         


        
7条回答
  •  无人及你
    2020-12-16 02:17

    I simulated this problem and found that the success callback functions were only called when the html page was hosted on a web server and not when opened from a filesystem.

    To test I opened the file directly from my C: drive and it the callbacks didn't work and then hosted the file on Internet Information Services (IIS) and the callbacks did work.

    
    
    
    
    

提交回复
热议问题