0

Have been looking around for some time now and didn't seem to find a solution that worked for me. I'm newbie regarding javascript (only done basic JAVA) but that haven't kept me from trying >D

I have to check whether a site exist before opening it. This is an example of a site not working:

Site not working

I tried this answer, but couldn't make it work. I notice that the tab in chrome does not have a header name like 404 or 404 Error. So was thinking if I could read other info from the site. Can I read the

         <h1>404 Not found</h1>

from the web site in the background and if it does not equal this string then direct the user to the site?

Community
  • 1
  • 1
Norfeldt
  • 8,272
  • 23
  • 96
  • 152
  • Is the content on the same domain, or on different sites? This will make a significant difference to how easy this is. – nrabinowitz Mar 09 '12 at 22:27
  • It tales the url from one site and change it so it get proxy access to to the payed content of the site. – Norfeldt Mar 15 '12 at 17:23

1 Answers1

0

Cross-domain ajax is tough. JavasScript is limited when it comes to accessing other domains, for security purposes. It may be easier to use a server-side scripting language like PHP (or an environment like Node.js) to do the checking. And then you would either use Ajax to ping the backend, or simply put an indicator right on the page when it's displayed.

Marshall
  • 4,716
  • 1
  • 19
  • 14
  • The script opens a new tab (in chrome). Can the script work on that tab or does it needs to be activated again? – Norfeldt Mar 15 '12 at 17:24