Skip to content

Instantly share code, notes, and snippets.

@ihsanberahim
Created August 8, 2014 07:26
Show Gist options
  • Save ihsanberahim/090738dd661616dc6761 to your computer and use it in GitHub Desktop.
Save ihsanberahim/090738dd661616dc6761 to your computer and use it in GitHub Desktop.
use hidden iframe to check whether the url alive or dead
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