Forum Moderators: travelin cat
<SCRIPT Language="Javascript" type="text/javascript">
<!--
var mac=-1;
var anchor='';
if (navigator.userAgent) {mac=navigator.userAgent.search(/Mac/);}
function loaded(){
if (mac!=-1) {anchor='home';} else {anchor='#home';}
if (! window.location.hash) {window.location.hash=anchor;}
setTimeout('enter()',4000);
}
function enter(){
if (window.location.hash==anchor) {
if (mac!=-1) {anchor='enter';} else {anchor='#enter';}
window.location.hash=anchor;
}
}
//-->
</SCRIPT>
The function 'loaded()' is called through an onLoad event handler in the BODY tag.
The separate scripting for Macs was necessary because I found out that here the #-sign is internally added to the anchor name (both on IE5 and Safari) and otherwise would therefore appear twice.
However, what happens with the above script is that the function loaded() changes the window location to #home but nothing more (i.e. it either fails to execute the setTimeout() command or the function 'enter()').
On a PC this works perfectly with all browsers, but as mentioned, on Macs (I tested this in an Internet Cafe on an iMac) it fails with IE5.0, IE5.2 as well as Safari.
Any suggestions?
function loaded(){
if (mac!=-1) {anchor='home';} else {anchor='#home';}
if (window.location.href.search(/#/)==-1) {window.location.hash=anchor; home=1;}
setTimeout('enter()',4000);
}
function enter(){
if (home==1) {
if (mac!=-1) {anchor='enter';} else {anchor='#enter';}
window.location.hash=anchor;
}
}
At least the redirect works now although it still does not recognize the # in the referrer (on Opera/PC) but this is of minor importance.