Invalid or unexpected token错误,不知如何解决
遇到了一个错误,找了好几天,都不知道咋解决 Invalid or unexpected token 提示在js的第一句有错误,但是第一句没错呀,
这是js文件
window.onload=getMyLo[/color]cation;
function getMyLocation (){
if (navigator.geolocation)navigator.geolocation.getCurrentPosition(displayLocation,displayError);//displayLocation和displayError都是函数,因为函数也是一个值
else alert("Oops,no geolocation supprot");
}
function displayLocation(position){
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
var div= document.getElementById("location");
div.innerHTML="you are at Latitude:"+latitude+","+"Longitude:" +longitude;
}
function displayError(error){
var errorTypes={
0:"unknow error",
1:"Permission denied by user",
2:"Position is not available",
3:"Request timed out"};
var errorMessage =errorType[error.code];//使用error.code属性}
if(error.code==0||error.code==2){
errorMessage=errorMessage+" "+error.message;//对于错误0和2,有时error.message有额外的信息
}
var div=document.getEelementById("location");
div.innerHTML=errorMessage;
}/*地理定位会给处理程序传入一个error对象,error对象有一个code属性,其中包含1到3的一个数,多以现在要做的事情是把错误类型和错误消息关联起来*/
这是html文件
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Where am I?</title>
<script src="myLoc.js"></script>
</head>
<body>
<div id="Location">Your Location will go here.</div>
</body>
</html>
...全文
相关推荐
JS提示:Uncaught SyntaxError:Unexpected token ) 错误的解决方法
主要介绍了JS提示:Uncaught SyntaxError:Unexpected token ) 错误的解决方法,结合实例形式分析了javascript提示此类异常的常见原因与相关解决方法,需要的朋友可以参考下
唯一解决 Protel 99 SE 'Format '%x' invalid or incompatible 的方法
唯一解决 Protel 99 SE 'Format '%x' invalid or incompatible with argument' 的方法 4核的电脑
引入mybatis-plus报 Invalid bound statement错误问题的解决方法
主要介绍了引入mybatis-plus报 Invalid bound statement错误问题的解决方法,需要的朋友可以参考下
解决 Protel 99 SE 'Format '%x' invalid or...
大家在使用Protel 99 SE时在导入自定义库时是否经常遇到莫名其妙的弹窗 'Format '%x' invalid or 问题,此资源提供了彻底解决此问题的办法,内有解决工具和说明文件。
format ' x' invalid or incompatible with argument 解决办法
format ' x' invalid or incompatible with argument 解决办法


