Atom-G Posted June 24, 2006 Share Posted June 24, 2006 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 More sharing options...
Webworldx Posted June 25, 2006 Share Posted June 25, 2006 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 More sharing options...
Atom-G Posted June 27, 2006 Author Share Posted June 27, 2006 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 More sharing options...
Chocolate570 Posted June 28, 2006 Share Posted June 28, 2006 Can't you just load the page into an iframe and check if it's loaded? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now