Check if the pc is connected to internet?

Hi dear forum,
Is it possible to check via script if the pc is actually connected to internet?
I should put the script in the CB script box in order to show different messages if the pc is connected or not.
you could simply try to load a file from a direct internet adress, and if that fails the computer is not connected.

however it would really help if you describe what and why you want to do, because that can cause some indirect problems - especially with your antivirus...
Simple:
window.navigator.onLine

Code:
if ( window.navigator.onLine ){
console.log("You are online");
}else{ console.log("Not connected");}
Simple:
window.navigator.onLine

Code:
if ( window.navigator.onLine ){
console.log("You are online");
}else{ console.log("Not connected");}
That only returns true if there is a connection to the LAN network, not necessarily means there's internet.

More info
you could simply try to load a file from a direct internet adress, and if that fails the computer is not connected.

however it would really help if you describe what and why you want to do, because that can cause some indirect problems - especially with your antivirus...

I was thinking to implement this: http://yanfly.moe/2015/10/25/yep-021-external-links/
So I wanted that the NPC who should open the link can say: "Hey you are not connected!" instead of simply open a useless window.

Simple:
window.navigator.onLine

Code:
if ( window.navigator.onLine ){
console.log("You are online");
}else{ console.log("Not connected");}

I guess this is what I need! I tested it and it works, thank you!

That only returns true if there is a connection to the LAN network, not necessarily means there's internet.

More info

Thank you too for the additional info!
Then thaw will work as a first check, and if the file fails to load through yep external links give an error saying "it failed to load (maybe there is an internet connection issue)"

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/check-if-the-pc-is-connected-to-internet.130693/