I am using jqueryUI/jquerymobile for an WebApp. There is a button which should check if the user is connected to the internet or not. Wether he is or not the href of the link should change. I tried the following but it does not work. Any ideas why? It opens the link to http://test.com every time, no matter if online or offline.
<script type="text/javascript">
function OnClick () {
if ('onLine' in navigator) {
if (navigator.onLine) {
window.location = "http://test.com/";
}
else {
window.location = "test.html";
}
}
else {
alert ("Your browser does not support the onLine property.");
}
}
</script>
<li class="ui-corner-none nav2"><a href="http://test.com/" onClick="OnClick ()">Link</a></li>