2014-08-29 40 views
2

的位置太多了,我有一個singn_up-form並使用Google-Api給用戶一些建議。 API在Internet-Explorer中請求用戶的位置。但是如果我嘗試使用Firefox,請求會一直循環,直到我點擊「Standort immer Freigeben」 - 它表示「始終接受」。google.maps.places.Autocomplete請求在我的網站中火狐

function initialize() { 
    autocomplete = new google.maps.places.Autocomplete(
    (document.getElementById('autocomplete')), 
    { types: ['geocode'] }); 
} 

代碼在document.ready中加載幷包含更多代碼,但此代碼片段也會重現錯誤。 有沒有人有一些想法?

回答

0

試試這個: 把蜜蜂在你<head></head>

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3&sensor=false&libraries=places"></script> 

把這個在你的身體標記:

<label for="autocomplete">Please Insert an address:</label> 
<br> 
<input id="autocomplete" type="text" size="100"> 

把這個在您的onload功能:

var input = document.getElementById('autocomplete');  
new google.maps.places.Autocomplete(input); 

這是我的代碼:

var input = document.getElementById('autocomplete');  
 
new google.maps.places.Autocomplete(input);
<html> 
 
    <head> 
 
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3&sensor=false&libraries=places"></script> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
    </head> 
 
    <body> 
 
    <label for="autocomplete">Please Insert an address:</label><br> 
 
    <input id="autocomplete" type="text" size="100"> 
 
    </body> 
 
</html>

0

你可能已經保存了一些的onfocus屬性爲Google Maps API Example

<input id="autocomplete" placeholder="Enter your address" onFocus="geolocate()" type="text"></input> 

OR

給出如果您不需要保留界的地方建議,您可能希望刪除它

如果您需要設置建議範圍,請保留一些條件,以便每次都不要發出位置同意,如果用戶給予許可。

請保持您的病情在geolocate() function

問題只在Mozilla Firefox

正在發生