phonegap双重重定向脱机网络连接

时间:2016-10-19 07:27:49

标签: cordova redirect connection offline

在没有连接或离线时尝试在phonegap上获得双重定向,但屏幕保持空白

<!DOCTYPE html>
<html>    
<head>
<script type="text/javascript">    
    function onDeviceReady() {    
        InternetOK();    
    }
    function InternetOK() {    
        var networkState = navigator.connection.type;    
        if (networkState == Connection.NONE ){ 
            window.location = 'offline.html';    
        } else {
            window.location = 'app.html';
        }    
    document.addEventListener("deviceready", onDeviceReady, false);
</script>            
</head>    
<body>            
</body>    
</html>   

1 个答案:

答案 0 :(得分:0)

请在cordova.js代码

之后添加<head>
<script src="cordova.js"></script>