【问题标题】:how to check Internet connection is have or not and if don't have how to show internet not connect in the popup using jquery in worklight如何检查 Internet 连接是否有,如果没有如何在 worklight 中使用 jquery 在弹出窗口中显示 Internet 未连接
【发布时间】:2016-03-24 12:15:31
【问题描述】:

应用程序午餐或任何使用互联网调用的功能我想检查互联网是否连接,所以我想显示如果 internet connection not connected in popup 如何在 worklight hybrid mobile application 中使用 jquery mobile .

请任何人告诉我这是怎么做的,任何人有样品请把它放在这个问题中。

我写下面的代码。

//main.js

var busyIndicator=null;

function wlCommonInit(){
	
	busyIndicator = new WL.BusyIndicator('page', {text : 'Please Wait...'},{minDuration: '1s'},{color: "red"});
	
	isOnline();
}



function isOnline() {
    var online = navigator.onLine;    // Detecting the internet connection
    if(online) {
    	alert('You\'re online now...');
    } else {
       alert('You\'re Offline now...');
      
      $("#errorPopup").popup("open");
    }
}
<!--index.html -->

<div data-role="page" id="page">
    			<div data-role="content" style="padding: 15px">
    				<input type="text" id="txtTrtDtPreAprvlSubn" 
				placeholder="Treatment Date" required="required" autocomplete="off"
				spellcheck="false" readonly="readonly">
    			</div>

	</div>


<div data-role="popup" id="errorPopup" data-overlay-theme="b"
			data-theme="b" data-corners="false" align="center">
			<p>internet connection not connected</p>
</div>

【问题讨论】:

标签: jquery popup ibm-mobilefirst internet-connection


【解决方案1】:

首先。你可以很容易地找到这个答案。但是,你可以实现流式 API WL.Device.getNetworkInfo 。在应用程序启动时检查 Internet 连接并根据结果执行操作。

function wlCommonInit() {
    WL.Device.getNetworkInfo(function (networkInfo) {
        alert (networkInfo.isNetworkConnected);
        if (networkInfo.isNetworkConnected) { // if true, then
            // connect to the Worklight Server or do something else...
        }
    });

您也可以查看这张幻灯片http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v600/05_04_Working_offline.pdf

【讨论】:

    猜你喜欢
    • 2016-04-07
    • 2016-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-23
    相关资源
    最近更新 更多