[問題]HTML5判定讀者所在位置的功能叫不出來?
各位前輩好~最近小弟正在學習HTML5的地圖功能
但讓我百思不解的是我拿head first上的範例程式作實驗卻一直不成功.....
=================================================
<div id="location">
Your location will go here
</div> 這段是要拿來回傳位置的
================================================
window.onload=getMylocation;
function getMylocation(){
if(navigator.geolocation)
{navigator.geolocation.getCurrentPosition(displayLocation);}
else
{alert("Oops,no geolocation support")}
}
function displayLocation(Position){
var latitude=position.coords.latitude;
var longitude=position.coords.longitude;
var div=document.getElementById("location");
div.innerHTML="Your are at latitude "+ latitude +", longitude: "+longitude;
}
上面這段是拿來得到位置並回傳
====================================================
我是在firefox執行的但是在瀏覽器要求我是否透露位置給他之後就無消無息ORZ
本來還有另一個偵錯函式我也打上去了~但是凡而沒反應連位置要求都沒反應.....
請問是哪裡出錯呢?我檢查好幾次了~應該沒打錯
是我的網路有問題嗎==?
這是我的範例檔:
http://0rz.tw/zmNXb
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.133.166.93
推
08/22 11:41, , 1F
08/22 11:41, 1F
→
08/22 11:41, , 2F
08/22 11:41, 2F
推
08/22 12:05, , 3F
08/22 12:05, 3F
→
08/22 12:30, , 4F
08/22 12:30, 4F
→
08/22 12:34, , 5F
08/22 12:34, 5F
推
08/22 19:23, , 6F
08/22 19:23, 6F
→
08/22 19:25, , 7F
08/22 19:25, 7F
推
08/22 21:06, , 8F
08/22 21:06, 8F