【发布时间】:2014-06-20 22:40:44
【问题描述】:
如果设备无法连接,我将在此页面尝试从文件系统加载备份
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/about.css"/>
</head>
<body>
<ons-screen>
<ons-navigator title = "About">
<ons-page id="page" font-align="center">
</ons-page>
</ons-navigator>
</ons-screen>
</body>
<script type="text/javascript">
var page = document.getElementById("page");
if(navigator.connection.type != Connection.NONE){
page.innerHTML='<iframe src="http://www.website.com/about/" style="width:100%; height:100%;"></iframe>';
}else{
page.innerHTML='<iframe src="aboutBackup.html" style="width:100%; height:100%;"></iframe>';
}
</script>
</html>
我使用 github 说明 (https://github.com/apache/cordova-plugin-network-information/blob/master/doc/index.md) 安装了插件
我不知道为什么,但是在我检查连接类型的第 22 行,我得到了 Uncaught TypeError: Cannot read property 'type' of undefined。
【问题讨论】:
标签: javascript cordova phonegap-plugins