Re: [問題] 請問前端可以判斷網頁進不進的去嗎?
好像可以,我無聊試了一下
東拼西湊醜了點
<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('Test1" rel="nofollow">http://www.google.com')">Test1</button>
<button
onclick="fetchStatus('Test2" rel="nofollow">http://www.ggwrugkaawieughla.com')">Test2</button>
</body>
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.229.246.221
※ 文章網址: https://www.ptt.cc/bbs/Web_Design/M.1471277217.A.AF4.html
推
08/16 19:41, , 1F
08/16 19:41, 1F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
Web_Design 近期熱門文章
PTT數位生活區 即時熱門文章