FRIHOST • FORUMS • FAQ • TOS • BLOGS • DIRECTORY
You are invited to Log in or Register a Frihost Account!

java script checking page

 


gandalf88
is it possible that a java script on a page checks if a page is on line, and redirects to this site, and otherwise to another site?
biljap
To redirect a viewer instantly, you just need to add a short command in your head section:
Code:
<HEAD>
<SCRIPT language="JavaScript">
<!--
window.location="http://someplace.com";
//-->
</SCRIPT>
</HEAD>

This would take the viewer right to the url you used as soon as they start loading the page. Another use for it is to redirect your viewers to the specific page depending of some choices:
Code:
<HEAD>
<SCRIPT language="JavaScript">
<!--
if (choice=="choice1")
{
window.location="http://www.someplace.com/choice1.html";
}
else
{
 if (choice=="choice2")
 {
  window.location="http://www.someplace.com/choice2.html";
 }
 else
  {
   window.location="http://www.someplace.com/default.html";
   }
}
//-->
</SCRIPT>
</HEAD>



I don’t know how to check if a page is available.

You can create a 404 error trap yourself that will redirect all code 404 errors (page not found) to your page. Take a look at http://www.dwfaq.com/Tutorials/Miscellaneous/custom_error_page.asp
Straevaras
Make a frame, send the frame to the address and check the location of the frame, so see if it reached the site or got forwarded to the 401 page on your hard drive. I've never actually attempted that, but I'd say it's worth a shot. You'd have to use JavaScript though in order to find out the location of the frame, and you'll probably have to look that up, too, since I don't know it off the top of my head. Wink

I'm not sure if it will work, but try it. If it does work, let me know. Very Happy
aningbo
that wuld be a near impossible code but let us know if you happen to get it working. i dont think its possible though.
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.