Home > Web Front-end > JS Tutorial > body text

Use js to determine whether the client can access the Internet (code attached)

亚连
Release: 2018-05-18 09:38:58
Original
1593 people have browsed it

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>
Copy after login

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 () {
        //放一些只有上网才能做的代码
        }
  );
Copy after login

or

//跨域(可跨所有域名)    
$.getJSON("http://e.hnce.com.cn/tools/ajax.aspx?jsoncallback=?", { id: 0, action: &#39;jobcategoryjson&#39; }, 
function(json) {
         alert(json[0].pid);        
         alert(json[0].items[0]._name);
             });
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template