How does js determine whether the user's network is useful? That is, I want to determine whether the user can use the external network? And make sure he has access to the Internet? God, please help me. . .
三叔2017-07-05 11:09:13
Request an external network address in the background and see if it can be returned normally.
淡淡烟草味2017-07-05 11:09:13
$.ajax({
url: '/',
success: res => alert('应该有网'),
error: () => alert('应该没网')
});
Want to try it?
我想大声告诉你2017-07-05 11:09:13
You can use it directly, or learn from https://www.npmjs.com/package/ping