I have a function that check mobile internet.

This function work of click(OnClick Function)
I would that work automatically when app launch! 

How do i do?

The function is this:

```
<script>
function checkJSNetConnection(){
 var xhr = new XMLHttpRequest();
 var file = "dot.png";
 var r = Math.round(Math.random() * 10000); 
 xhr.open('HEAD', file + "?subins=" + r, false); 
 try {
  xhr.send(); 
  if (xhr.status >= 200 && xhr.status < 304) {
   return true;
  } else {
   return false;
  }
 } catch (e) {
  return false;
 }
}

    function onJSButtonclick(){
     if(checkJSNetConnection()==true){
      alert("Internet Connection Exists");
     }else{
      alert("Internet Connection Doesn't Exist");
     }
    }
    </script>

```