Jump to content

Verifying if a website is offline or online


Atom-G

Recommended Posts

Hi all of you,I already did a website in PHP where it will verify 41 websites, if they are online or not. I use simply fopen. But this take a while to load, like up to 10s to 100s.So I would like to make a page in javascript to make it more "instant", always loading page. I tryed using XMLHttpRequest.open but I keep having this error: "Permission denied to call method XMLHttpRequest.open". After reading on the net, I now know that we cannot use this method to access a external website of our domain, for security reason.Now my question is: What other functions/method I could use to verify if a website is offline or not? With XMLHttpRequest.open I was verifying the "if (xx.readyState == 4) & if (xx.status == 200)".What you guys would do?Thank you. :)

Link to comment
Share on other sites

You can't use XMLHttpRequest cross site, so that's not an option.How about something like:

<script type='text/javascript'>function site_noexist(){	alert('there was an error loading the image from the site');}//This will work, as the image exists on the site, and can be reached.var testSite = new Image();testSite.onerror = site_noexist;testSite.src = 'http://www.google.co.uk/intl/en_uk/images/logo.gif';//This will fail, as the site gogle does not hold the image.var testSite = new Image();testSite.onerror = site_noexist;testSite.src = 'http://www.gogle.co.uk/intl/en_uk/images/logo.gif';</script>

Link to comment
Share on other sites

hum, thats kind of nice. We are limited to the image, but not bad at all.Is there any proxy check or something? When I was reading on the net, peopl where saying to look for proxy etc, but not saying what method to use....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...