这是我在基于 phonegap 的应用程序中使用的代码,带有 sencha touch。我尝试检查互联网连接是否可用。警报仅在连接可用时有效。当互联网连接失败时,它不会显示警报。代码如下
<!DOCTYPE HTML><html lang=en-US>
<head>
<meta http-equiv=Cache-control content=no-cache />
<meta name=format-detection content="telephone=no"/>
<meta name=apple-mobile-web-app-capable content=yes />
<title>WishList</title>
<link rel="stylesheet" href="resources/css/sencha-touch.css" />
<link rel="stylesheet" href="resources/css/app.css" />
<link href="resources/css/mobiscroll.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var a=navigator.onLine;
if(a){
alert('online');
}else{
Ext.Msg.alert("Alert!", "Please check your internet connection!");
}
</script>
<script src="libraries/sencha/sencha-touch-all.js" defer></script>
<script src="libraries/jquery/jquery.1.10.1.js" defer></script>
<script src="libraries/mobiscroll/mobiscroll.min.js" type="text/javascript" defer> </script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
<script src="app/views/app.js" defer></script>
<script src="app/views/JSfunctions.js" defer></script>
<script type="text/javascript" src="app/views/cordova.js"></script>
</head>
<body>
</body>
</html>
代码有什么问题?请帮助我