Find jobs - ROKR E6 - Indian television shows news - Find jobs - Free Advertising

PDA

View Full Version : Need help with this bit of code.


joesgraphics
Feb 16th 2007, 7:11 am
my friend needs some help with some javascript but i dont do javascript so i fort some 1 on here could help

He is useing this for the onload bit of the script.
<?php if ( $video == "" ) {} else { echo "<body onload=\"javascript:ScrollWin()\">";}?>




this is the javascript.

the thing is that it works with firefox but no i.e. is there a fix so it will work in I.E.
<!--
scrollSteps = 100
timer=""
moz=document.getElementById&&!document.all

function scrollDiv(id){
clearTimeout(timer)
scrollingDiv=document.getElementById("playlist")
if((moz||window.opera)&&!scrollingDiv.style.position){
browserOffset=scrollingDiv.offsetTop
}
else{
browserOffset=0
}

if(scrollingDiv.scrollTop <= document.getElementById(id).offsetTop-scrollSteps-browserOffset){
scrollingDiv.scrollTop=document.getElementById("playlist").scrollTop+scrollSteps
timer=setTimeout("scrollDiv('"+id+"')",10)

// if bottom of page reached before anchor point
if(scrollingDiv.scrollTop>(scrollingDiv.scrollHeight-scrollingDiv.offsetHeight)-scrollSteps){
clearTimeout(timer)
scrollingDiv.scrollTop=document.getElementById("playlist").scrollHeight-scrollingDiv.offsetHeight
}

}
else{

if(scrollingDiv.scrollTop >= document.getElementById(id).offsetTop+scrollSteps-browserOffset){
scrollingDiv.scrollTop=document.getElementById("playlist").scrollTop-scrollSteps
timer=setTimeout("scrollDiv('"+id+"')",10)
}
else{
clearTimeout(timer)
scrollingDiv.scrollTop=document.getElementById(id).offsetTop-browserOffset
}

}

}

function toTop(){
scrollingDiv=document.getElementById("playlist")
clearTimeout(timer)
if(scrollingDiv.scrollTop >= scrollSteps){
scrollingDiv.scrollTop=document.getElementById("playlist").scrollTop-scrollSteps
timer=setTimeout("toTop()",10)
}
else{
clearTimeout(timer)
scrollingDiv.scrollTop=0
}

}

// -->

nico_swd
Feb 16th 2007, 7:43 am
echo "<body onload=\"javascript crollWin()\">"


There is no function called "crollWin". It probably should be scrollWin.. but that doesn't exist either.

Plus it's not the correct method to call a function ONxx. It should be just onxxx="MyFunction()". (Without the "javascript")

joesgraphics
Feb 16th 2007, 9:17 am
sorry error in the onload thing its scrollwin not crollwin