我想创建jquery监听器来检查互联网连接.
function checkInternetConnection()
{
onConnectionClosed:function(){
dialog.show("Connection closed please wait");
}
onConnectionOpened:function(){
dialog.hide();
}
}
$(document).ready(function(){
checkInternetConnection();
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>Run Code Online (Sandbox Code Playgroud)
因此,当关闭连接时,我想向用户显示一个对话框.当连接回来时我想隐藏对话框.我怎样才能做到这一点?