...

View Full Version : Floating or static layers in IE4 error



blaquekaat
07-25-2002, 05:36 PM
Im getting an error message in the IE4 browser for a floating or static layer script on every page. Once OK is clicked the code does work. Please help. Thanks in advance

<script language = "javascript">
<!--

var ns6 = (document.getElementById && !document.all) ? 1 : 0
var ie = document.all ? 1 : 0
var ns = document.layers ? 1 : 0


var master = new Object("element")
master.curLeft = -120; master.curTop = 10;
master.gapLeft = 0; master.gapTop = 0;
master.timer = null;

function moveAlong(layerName, paceLeft, paceTop, fromLeft, fromTop){
clearTimeout(eval(layerName).timer)

if(eval(layerName).curLeft != fromLeft){
if((Math.max(eval(layerName).curLeft, fromLeft) - Math.min(eval(layerName).curLeft, fromLeft)) < paceLeft){eval(layerName).curLeft = fromLeft}
else if(eval(layerName).curLeft < fromLeft){eval(layerName).curLeft = eval(layerName).curLeft + paceLeft}
else if(eval(layerName).curLeft > fromLeft){eval(layerName).curLeft = eval(layerName).curLeft - paceLeft}

if(ns6){document.getElementById(layerName).style.left = eval(layerName).curLeft}
if(ie){document.all[layerName].style.left = eval(layerName).curLeft}
if(ns){document[layerName].left = eval(layerName).curLeft}
}

if(eval(layerName).curTop != fromTop){
if((Math.max(eval(layerName).curTop, fromTop) - Math.min(eval(layerName).curTop, fromTop)) < paceTop){eval(layerName).curTop = fromTop}
else if(eval(layerName).curTop < fromTop){eval(layerName).curTop = eval(layerName).curTop + paceTop}
else if(eval(layerName).curTop > fromTop){eval(layerName).curTop = eval(layerName).curTop - paceTop}

if(ns6){document.getElementById(layerName).style.top = eval(layerName).curTop}
if(ie){document.all[layerName].style.top = eval(layerName).curTop}
if(ns){document[layerName].top = eval(layerName).curTop}
}

eval(layerName).timer=setTimeout('moveAlong("'+layerName+'",'+paceLeft+','+paceTop+','+fromLeft+','+fromTop+')',30)
}

function setPace(layerName, fromLeft, fromTop, motionSpeed){
eval(layerName).gapLeft = (Math.max(eval(layerName).curLeft, fromLeft) - Math.min(eval(layerName).curLeft, fromLeft))/motionSpeed
eval(layerName).gapTop = (Math.max(eval(layerName).curTop, fromTop) - Math.min(eval(layerName).curTop, fromTop))/motionSpeed

moveAlong(layerName, eval(layerName).gapLeft, eval(layerName).gapTop, fromLeft, fromTop)
}


var expandState = 0

function expand(){
if(expandState == 0){
setPace("master", 0, 10, 10);
if(ie){document.menutop.src = "/i/bl/stories/6958380/menubar.gif"}; expandState = 1;}
else{setPace("master", -120, 10, 10);
if(ie){document.menutop.src = "/i/bl/stories/6958380/menubar.gif"}; expandState = 0;}
}

function FixY(){
if(ns6){document.getElementById("master").style.top = window.pageYOffset+10}
if(ie){document.all.master.style.top = document.body.scrollTop+10}
if(ns){document.master.top = window.pageYOffset+10}
}

setInterval("FixY()",100);

//-->
</script>

Mrs G
07-25-2002, 08:24 PM
When I tried your script I got the following error message.

Unterminated String Constant

If this is the error you get change the following line


eval(layerName).timer=setTimeout('moveAlong("'+layerName+'" ,'+paceLeft+','+paceTop+','+fromLeft+','+fromTop+'
)',30)


for this line

eval(layerName).timer=setTimeout("moveAlong('+layerName+' ,'+paceLeft+','+paceTop+','+fromLeft+','+fromTop+')",30)

blaquekaat
07-25-2002, 09:08 PM
I tried your script, unfortunately it didnt work I still got the unterminated string error

Mrs G
07-26-2002, 11:11 PM
At which line number?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum