简体   繁体   中英

Detect internet connection in cross browser platform


I need to detect internet connection in my js file. i used Navigator.Online but it is not reliable especially in the Firefox and Safari. Only chrome seems to return right output. I also came across wonderful jquery plugin checkNet but after analyzing it, i found it is only checking for server not for internet because when i run it in local it checks it from xammp server

this are the links which i used for reference

http://tomriley.net/blog/archives/111
Check if Internet Connection Exists with Javascript?
Jquery Plugin for Detecting Internet Connection

Is there other easy way to check internet connection using jquery/Java script in all browsers. I need to check the internet connection not the server error and i am also dealing with cross domain ie data is passed between two different domains/servers

here is navigator online code which i used but it does not seems to work perfectly

var netCheck = navigator.onLine ? 'online' : 'offline'; 

any thing jquery, javascript or PHP solution will work

您可以尝试跳出一些地址,跳出框框思考;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM