Created
August 8, 2014 07:26
-
-
Save ihsanberahim/090738dd661616dc6761 to your computer and use it in GitHub Desktop.
use hidden iframe to check whether the url alive or dead
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkUrl(url, callback) | |
{ | |
var iframe = document.createElement('IFRAME'); | |
iframe.src = url; | |
iframe.style.visibility = 'hidden'; | |
document.body.appendChild(iframe); | |
iframe.onload = function() | |
{ | |
if(callback) | |
try | |
{ | |
callback(typeof iframe.contentWindow.document!=="null"); | |
}catch(e) | |
{ | |
callback(false); | |
} | |
document.body.removeChild(iframe); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment