我有一個功能,檢查移動互聯網。改變從點擊到開啓加載的活動功能
這個功能點擊工作(OnClick Function) 我會在應用程序啓動時自動工作!
我該怎麼辦?
的功能是這樣的:
<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>
偉大的:) ....... – user3682743