Re: [問題] 請問前端可以判斷網頁進不進的去嗎?

看板Web_Design作者 (卡比)時間9年前 (2016/08/16 00:06), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
好像可以,我無聊試了一下 東拼西湊醜了點 <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
文章代碼(AID): #1NiUYXhq (Web_Design)
文章代碼(AID): #1NiUYXhq (Web_Design)