使用PhoneGap。。。
如果用户没有网络连接,我想找到一种方法来阻止数据角色="页面"的导航。我很难找到任何资源,我在谷歌上搜索了几个小时,尽管我可能使用了错误的术语。
我希望用户只有在有网络连接的情况下才能在这里导航:
<div data-role="page" id="Location">
<div data-role="header" data-theme="e">
<a href="#" data-rel="back">Incid..</a>
<h1>
Location</h1>
<a href="#" data-rel="back" onclick="updateLoc()" data-theme="g">Use Current</a>
</div>
<!-- /header -->
<div data-role="content">
<!--<div id="panel">
<input id="target" type="text" placeholder="Search Box">
</div>-->
<div id="map_canvas">
</div>
</div>
对pageshow
:使用此jQuery
$('#Location').live('pageshow', function (event, ui) {
try {
display();
}
catch (e) {
log(e);
alert(e);
}
});
我知道我应该能够使用if(navigator.network.connection.type=='none')来捕捉网络状态,但我很难阻止显示"位置"页面。
根据用户是否有网络连接,使用$.mobile.changePage('#pageID')
更改页面。