javascript - Change active function from on click to on load -
i have function check mobile internet.
this function work of click(onclick function) work automatically when app launch!
how do?
the function 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>
try :
$(document).ready(function(){ onjsbuttonclick(); });
add before closing </script>
tag.
Comments
Post a Comment