2012-11-20 30 views
0

我已经通过几个同样的问题也消失了,但没有人可以给我的理解是什么在我的代码正在发生的事情。我的代码是:代码在Firefox工作正常,无法在Chrome

if (navigator.geolocation) { 

      console.log(" in navigator If"); 
      navigator.geolocation.getCurrentPosition(showPosition, null, { 
       enableHighAccuracy : true, 
       maximumAge : 1000, 
       timeout : 0 
      }); 

     } else { 
      console.log("in Navigator else"); 
      alert("Browser doesn't support location detection. Please pass latitude & longitude for current location in URL. Thanks."); 
    } 

此代码工作在Firefox罚款,但不是在铬 我使用的是Mac,Jboss的。 在Chrome控制中没有任何条件(既不,如果,也不是)

+0

你在Chrome控制台中得到了什么样的错误信息(如果有的话)? – noj

+0

@jonnynnoj:没有错误控制台,甚至不问铬权限的位置.. – umesh

+0

只是测试它和我的“在导航如果”的消息,所以你的问题是在其他地方。 – noj

回答

0

如果您直接从chrome上的文件系统运行navigator.geolocation不起作用。确保该文件托管在某个本地Web服务器上。

+0

我提到过我使用的是Jboss,File是从Jboss – umesh

+0

开始的,然后是它的奇怪。请让我知道,如果你有任何解决办法。 –

相关问题