Link to home
Start Free TrialLog in
Avatar of RTKHOT
RTKHOTFlag for India

asked on

navigator.online not working

Please see this code:

if (localStorage.SurveyCompleted == 'True') {
                if (navigator.onLine) {
                    window.location.href = "Splash.htm";
                }
                else {
                    pfShowNetworkErrAlert();
                }    
            }

I am faced with a very strange issue.
If i am using my website on 1024 x 768 or 1366 x 768, then the above function works as it should.

BUT, on 1920 x 1080, it always goes in the 'if' part even though my machine is NOT online.  What is this weird issue? How do I resolve it?
Avatar of Pramod Kumar
Pramod Kumar
Flag of India image

Test this HTML:

<!DOCTYPE html>
<html>
<body>

<p id="demo">Click the button to see if the browser is online.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction()
{
var a = "onLine: "+navigator.onLine;
var b = "<br>appCodeName: "+navigator.appCodeName;
var c = "<br>appName: "+navigator.appName;
var d = "<br>appVersion: "+navigator.appVersion;
var e = "<br>cookieEnabled: "+navigator.cookieEnabled;
var f = "<br>platform: "+navigator.platform;
var g = "<br>userAgent "+navigator.userAgent ;

var x = a+b+c+d+e+f+g;
document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>

Open in new window

Avatar of RTKHOT

ASKER

I've requested that this question be deleted for the following reason:

wrong question
Avatar of RTKHOT

ASKER

PLEASE DO NOT DELETE THIS QUESTION.
Avatar of RTKHOT

ASKER

pramodkrjsr =>

my browser shows online even though the network cable was unplugged
Your reason "wrong question" is not clear to me. You said your browser showing online even the network is unplugged...that means you still have the issue. Why you wanted to close this question. Did us got the solution?
Avatar of RTKHOT

ASKER

Please do not delete this question. it was an accident

we have 4 machines.

on 2 of them, the browser is returning online even though the network cable is unplugged. so what could this issue be?
may be connected via some other wireless network (wifi) may be.
Avatar of RTKHOT

ASKER

No i checked that. there is no other connection. That's why I am wondering what this odd issue is
ASKER CERTIFIED SOLUTION
Avatar of Pramod Kumar
Pramod Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial