The following is the js I compiled for you to use to determine whether the client can access the Internet. Interested students can take a look.
The first type:
<script src=" <script language="javascript" type="text/javascript"> if(!window.jQuery) { alert("能上网"); }else{ alert("不能上网"); } </script>
The second type:
Use js to do cross-domain
$.getScript("http://api.taobao.com/apitools/ajax_props.do?act=props&cid=50000436&restBool=false", function () { //放一些只有上网才能做的代码 } );
or
//跨域(可跨所有域名) $.getJSON("http://e.hnce.com.cn/tools/ajax.aspx?jsoncallback=?", { id: 0, action: 'jobcategoryjson' }, function(json) { alert(json[0].pid); alert(json[0].items[0]._name); });
The above is the js I compiled for you to use to determine whether the client can access the Internet. I hope it will be helpful to everyone in the future.
Related articles:
Interview questions about AJAX (with answers)
Detailed analysis of the use of AJAX for you Method (code pasted)
Detailed interpretation of the code, string connection in Javascript
The above is the detailed content of Use js to determine whether the client can access the Internet (code attached). For more information, please follow other related articles on the PHP Chinese website!