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

Detailed explanation of js to determine whether the client can access the Internet

墨辰丷
Release: 2018-05-09 15:34:51
Original
1632 people have browsed it

This article mainly introduces js to determine whether the client can access the Internet in detail. Friends in need can refer to it.

The first one:

<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script language="javascript" type="text/javascript">
   if(!window.jQuery){
         alert("能上网");
    }else{
      alert("不能上网");
  }
Copy after login

The second one:

Use js to cross domain Do

$.getScript("http://api.taobao.com/apitools/ajax_props.do?act=props&cid=50000436&restBool=false", function () {

//Put Some codes that can only be done online

);

or

//Cross-domain (can cross all domain names)
$.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);

});


Related recommendations:

What are the methods for JS to determine json

How to use JS to determine whether the current page has scroll bars

js determines whether it is PC or mobile

The above is the detailed content of Detailed explanation of js to determine whether the client can access the Internet. For more information, please follow other related articles on the PHP Chinese website!

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