作者JaqqXD (卡比)
标题Re: [问题] 请问前端可以判断网页进不进的去吗?
时间Tue Aug 16 00:06:53 2016
好像可以,我无聊试了一下
东拼西凑丑了点
<html>
<head>
<script src="
https://code.jquery.com/jquery-1.12.4.js"
integrity="sha256-Qw82+bXyGq6MydymqBxNPYTaUXXq7c8v3CwiYwLLNXU="
crossorigin="anonymous"></script>
<script>
function fetchStatus(url) {
$.ajax({
url: url,
timeout: 2000,
type: 'GET',
crossDomain: true,
dataType: 'jsonp',
success: function() { alert("Success"); },
error: function(x, t, m) {
if(t==="timeout") {
alert('invalid');
} else {
alert('valid');
}
}
});
}
</script>
</head>
<body>
<button onclick="fetchStatus('
http://www.google.com')">Test1</button>
<button
onclick="fetchStatus('
http://www.ggwrugkaawieughla.com')">Test2</button>
</body>
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 36.229.246.221
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Web_Design/M.1471277217.A.AF4.html
1F:推 yongb: 谢谢大大~~ 08/16 19:41