Need help with this bit of code.

Discussion in 'JavaScript' started by joesgraphics, Feb 16, 2007.

  1. #1
    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()\">";}?>
    PHP:



    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
    }
    
    }
    
    // -->
    PHP:

     
    joesgraphics, Feb 16, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
     echo "<body onload=\"javascript crollWin()\">"
    
    Code (markup):
    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")
     
    nico_swd, Feb 16, 2007 IP
  3. joesgraphics

    joesgraphics Peon

    Messages:
    206
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sorry error in the onload thing its scrollwin not crollwin
     
    joesgraphics, Feb 16, 2007 IP