I am developing a phone gap application for which I am supporting Android, BlackBerry, iphone and Windows Phone 7. The internet connectivity check is not working in windows phone 7 alone. There are separate cordova.js file for each platform so I am keeping these files in different folders with corresponding name like android, iphone, etc. I am dynamically loading the js file based on the type of device the application is getting loaded, say if the application is running in Android I am loading android/cordova.js. It is working fine in all platforms except for Windows Phone. If I load the js file directly in the head tag, the connectivity check is working in windows phone 7 where as loading the js file dynamically is not working. I will give the code snippet below (file path is correct I have checked it)
<script type="text/javascript" charset="utf-8">
function test() {
$('head').append('<script type="text/javascript" src="' + filePath + '"' + '></' + 'script>');
}
test();
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady(){
offLineModeTest();
}
function offLineModeTest(){
try {
var networkState = navigator.network.connection.type;
if (Connection.NONE == networkState || Connection.UNKNOWN == networkState) {
//do something......
}
}catch(err){
}
}
</script>