Saving variables outside of navigator.geolocation.getCurrentPosition? (javascript)

前端 未结 2 2017
感情败类
感情败类 2021-01-05 11:50

I\'m trying to play with the scope of js to pull a variable out of navigator.geolocation.getCurrentPosition

var lat;
function callback (position) {
    lat =         


        
2条回答
  •  囚心锁ツ
    2021-01-05 12:34

    You can save your Position variable to input hidden field on document ready. After that, you can use jQuery to get back Geolocation value

    Javscript:

    
    

    HTML:

         
        //value = position latitude on load
    

    To get back value:

    jQuery('#pos_lat').val();
    

提交回复
热议问题