Guide Test Connection Internet Javascript Degree

View: 537    Dowload: 0   Comment: 0   Post by: hanhga   Category: Javascript   Fields: Other

As you can see on Facebook and Gmail notification function status of your Internet and inform the user that this function is quite handy because you can store important information on the Client and at the Internet will continue handling. If you were to do such a function, then view it this, I'll describe how to test internet connection Javascript

I do not know Gmail and Facebook to learn how code but I know one way is to use Ajax request to an image (image as small as possible, can choose a 1px x 1px) and based on the request header to know the internet connected or not. In this way, the picture that you place in your server offline.
1. Test Connection Internet Javascript Degree
To check your internet connection uses the following JavaScript function:

function doesConnectionExist() {
    var xhr = new XMLHttpRequest();
    var file = "http://laptrinhweb.anythingvn.com/laptrinhweb.png";
    var randomNum = Math.round(Math.random() * 10000);
 
    xhr.open('HEAD', file + "?rand=" + randomNum, false);
 
    try {
        xhr.send();
 
        if (xhr.status >= 200 && xhr.status < 304) {
            return true;
        } else {
            return false;
        }
    } catch (e) {
        return false;
    }
}

I do not know Gmail and Facebook to learn how code but I know one way is to use Ajax request to an image (image as small as possible, can choose a 1px x 1px) and based on the request header to know the internet connected or not. In this way, the picture that you place in your server offline.
1. Test Connection Internet Javascript Degree
To check your internet connection uses the following JavaScript function

function check()
{
    if (!doesConnectionExist()){
        // Code lưu trữ thông tin
        // Code thông báo người dùng
        // ..
    }
}
 
setTimeout(function(){
    check();
}, 10000);

2. Epilogue

The way out of his very simple but quite effective. But is a Javascript library used exclusively to check the Internet site Offline.js library that you downloaded to refer offline because it is written very much more professional.

Guide Test Connection Internet Javascript Degree

As you can see on Facebook and Gmail notification function status of your Internet and inform the user that this function is quite handy because you can store important information on the Client and at the Internet will continue handling

Posted on 19-12-2015 

Comment:

To comment you must be logged in members.

Files with category

  • Data Visualization for BI: How to Design Layouts for .NET Financial Reports

    Data Visualization for BI: How to Design Layouts for .NET Financial Reports

    View: 10    Download: 0   Comment: 0

    Category: Javascript     Fields: Other

    With the Active Reports Server, you can have a multi-tenant environment where users from various departments, companies, or other specifications can log in, view their reports (and only their reports), export the data, or set up a distribution...

  • AngularJS and REST API

    AngularJS and REST API

    View: 176    Download: 0   Comment: 0

    Category: Javascript     Fields: Other

    This is a tutorial for those interested in a quick introduction to AngularJS and REST API. We will build the familiar Periodic Table of the Elements found in every chemistry textbook, and allow the user to select a Chemical Element by clicking on...

  • Collective Intelligence, Recommending Items Based on Similar Users' Taste

    Collective Intelligence, Recommending Items Based on Similar Users' Taste

    View: 142    Download: 0   Comment: 0

    Category: Javascript     Fields: Other

    Using Collaborative Filtering to find people who share tastes, and for making automatic recommendations based on things that other people like.

  • Think Like a Bird for Better Parallel Programming

    Think Like a Bird for Better Parallel Programming

    View: 132    Download: 0   Comment: 0

    Category: Javascript     Fields: Other

    Coding an application to run in parallel is hard, right? I mean, it must be hard or we’d see parallel programs everywhere. All we'd see are slick parallel apps that use every available core effortlessly. Instead multi-threaded apps are the exception...

  • Getting Started with the Bing Search APIs

    Getting Started with the Bing Search APIs

    View: 136    Download: 0   Comment: 0

    Category: Javascript     Fields: Other

    Bing Search API is a set of REST interfaces that find web pages, news, images, videos, entities, related searches, spelling corrections, and more in response to queries from any programming language that can generate a web request. Applications that...

  • Brief Introduction of SocketPro High Performance and Scalable Persistent Message Queue

    Brief Introduction of SocketPro High Performance and Scalable Persistent Message Queue

    View: 451    Download: 0   Comment: 0

    Category: Javascript     Fields: Other

    Continuous in-line request/result batching, real-time stream sending/processing, asynchronous data transferring and parallel computation for best performance and scalability

  • Iteration Over Java Collections with High Performance

    Iteration Over Java Collections with High Performance

    View: 125    Download: 0   Comment: 0

    Category: Javascript     Fields: Other

    Java developers usually deal with Collections such as ArrayList, HashSet, Java 8 come with lambda and streaming API helps us to easily work with Collections. In most cases, we work with few thousands of items and performance isn't a concern. But in...

  • SR2JLIB - A Symbolic Regression Library for Java

    SR2JLIB - A Symbolic Regression Library for Java

    View: 140    Download: 0   Comment: 0

    Category: Javascript     Fields: Other

    Grammar-Guided Genetic Programming library featuring: multi-threading, just-in-time compilation of individuals, dynamic class loading, and JNI interfacing with C/C++ code

 
File suggestion for you
File top downloads
Codetitle - library source code to share, download the file to the community
Copyright © 2018. All rights reserved. codetitle Develope by Vinagon .Ltd