You are here: irt.org | FAQ | JavaScript | Event | Q1102 [ previous next ]
Obviously not on a page in either site since how would the user get the page in the first place? Perhaps from the cache?
On a third site you could use an image and use it's onError event handler:
<html> <head> <title>Some Site other than Main or mirror Site</title> <meta http-equiv="pragma" content="no-cache"> </head> <body> <img src="http.//www.mainsite.com/images/logo.gif" onError="location='http.//www.mirror.com/'"> </body> </html>
On the main site the user would have loaded the page from cache but then the image must not be cached:
<html> <head> <title>Main Site - page must come from cache</title> <script language="JavaScript"><!-- function testSite() { if (!document.images) return; today = new Date(); document.images["logo"].src = 'http.//www.mainsite.com/images/logo.gif?'+today.getTime(); } //--></script> </head> <body onLoad="testSite()"> <img name="logo" src="http.//www.mainsite.com/images/logo.gif" onError="location.href='http.//www.mirror.com/'"> </body> </html>