javascript - Determine user network environment
阿神
阿神 2017-07-05 11:07:13
0
3
969

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. . .

阿神
阿神

闭关修行中......

reply all (3)
三叔

Request an external network address in the background and see if it can be returned normally.

    淡淡烟草味
    $.ajax({ url: '/', success: res => alert('应该有网'), error: () => alert('应该没网') });

    Want to try it?

      我想大声告诉你

      You can use it directly, or learn fromhttps://www.npmjs.com/package/ping

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!