【发布时间】:2015-05-11 04:19:25
【问题描述】:
我正在为 android 创建 phonegap 应用程序。
我想检查应用程序的互联网连接。我正在使用offline.js。
但这对我来说根本不起作用。
我的代码是,
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>datePickerAngularTPLS</title>
<link href="css/offline.css" rel="stylesheet" />
<script src="scripts/jquery-1.11.3.min.js"></script>
<script src="scripts/offline.js"></script>
</head>
<body>
<script>
$(function () {
function on(evt) {
alert("connected successfully");
}
function off(evt) {
alert("connection failed");
}
Offline.on("up", on);
Offline.on("off", off);
});
</script>
<!-- Cordova reference, this is added to your app when it's built. -->
<script src="cordova.js"></script>
<script src="scripts/platformOverrides.js"></script>
<script src="scripts/index.js"></script>
</body>
</html>
上面的代码有什么问题...? 我只想在成功和失去互联网连接时显示警报。
我也尝试过使用 navigator.isOnlie,但不可靠。
【问题讨论】:
标签: javascript cordova phonegap-plugins offline internet-connection