2017-06-06 63 views
1

工作,我有這個基本的功能indentify用戶的位置:HTML 5 Geolocalization不會在Safari

function getLocation() 
{ 

if (navigator.geolocation) 
{ 

navigator.geolocation.getCurrentPosition(showmyPosition, errorCallback); 
} 
else 
{ 
alert("Geolocation is not supported by this browser."); 
} 
} 

function showmyPosition(position) 
{ 
document.location.href="/search?lat="+ position.coords.latitude +"&lng="+ position.coords.longitude +""; 
}  

function errorCallback(error) { 
if (error.code === 1) { 
alert("User denied geolocation"); 
} 
} 

正常工作在Firefox,Chrome和瀏覽器,但是,Safary不工作(既不在蘋果手機)。爲什麼?

回答