视图.html.erb
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
location();
</script>
切换.js
$(document).ready(function() {
$(function location()
{
alert("here in loc1233");
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(successFunction, errorFunction);
}
else {
alert("here in loc");
}
}); //showmap
$(function successFunction(position) {
var lat = position.coords.latitude;
var lot = position.coords.longitude;
alert('Your location coordinates are: Latitude:'+lat+' Longitude: '+lot);
});
});
在这里调用toggle.js中的函数location(),但它只给出警报
alert("在 loc1233");
它不会转到该函数中的其余行。为什么要这样奉献?
谢谢