SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    UK, London
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    scrolling using buttons designed with javascript

    Ok, i think it would be wise to say i am still a "newbie" at this!!.

    This is my second attempt at code to allow the user to view a table by navigating through a page using customised buttons. Although all buttons work on the 'MouseDown', event, the 'MouseUp' is not working. Any ideas?

    coding for the division=
    Code:
    <div style="background-color="orange";width:155"><center>
    <a href="javascript:movedown();"	onMouseDown="javascript:movedown();" 	onMouseUp="javascript:stopscroll();"><img src="down1.bmp" /></a>
    <a href="javascript:moveup();" 		onMouseDown="javascript:moveup();" 		onMouseUp="stopscroll();"><img src="top1.bmp" /></a>
    <a href="javascript:moveright();"	onMouseDown="javascript:moveright();" 	onMouseUp="stopscroll();"><img src="right1.bmp" /></a>
    <a href="javascript:moveleft();" 	onMouseDown="javascript:moveleft();"	onMouseUp="stopscroll();"><img src="left1.bmp" /></a>
    <a href="javascript:stopscroll();" 	onMouseDown="javascript:stopscroll();"><img src="stop1.bmp" ></a><br />
    <a href="javascript:movetop();"><b>Top of the table</b></a>
    <a href="javascript:moveside();"><b>side of the table</b></a><br /></center>
    </div>
    coding for the functions =
    Code:
    function movedown(){
    if (window.moveupvar) clearTimeout(moveupvar)
    if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+155))
    crossobj.style.top=parseInt(crossobj.style.top)-speed
    else if (ns4&&crossobj.top>=(contentheight*(-1)+100))
    crossobj.top-=speed
    movedownvar=setTimeout("movedown()",100)
    }
    
    function moveup(){
    if (window.movedownvar) clearTimeout(movedownvar)
    if (iens6&&parseInt(crossobj.style.top)<=0)
    crossobj.style.top=parseInt(crossobj.style.top)+speed
    else if (ns4&&crossobj.top<=0)
    crossobj.top+=speed
    moveupvar=setTimeout("moveup()",100)
    }
    
    function moveright(){
    if (window.moveleftvar) clearTimeout(moveleftvar)
    if (iens6&&parseInt(crossobj.style.left)>=(contentwidth*(-1)+100))
    crossobj.style.left=parseInt(crossobj.style.left)-speed
    else if (ns4&&crossobj.top>=(contentwidth*(-1)+200))
    crossobj.left-=speed
    moverightvar=setTimeout("moveright()",100)
    }
    
    function moveleft(){
    if (window.moverightvar) clearTimeout(moverightvar)
    if (iens6&&parseInt(crossobj.style.left)<=0)
    crossobj.style.left=parseInt(crossobj.style.left)+speed
    else if (ns4&&crossobj.left<=0)
    crossobj.left+=speed
    moveleftvar=setTimeout("moveleft()",100)
    }
    
    function stopscroll(){
    if (window.moveupvar) clearTimeout(moveupvar)
    if (window.movedownvar) clearTimeout(movedownvar)
    if (window.moverightvar) clearTimeout(moverightvar)
    if (window.moveleftvar) clearTimeout(moveleftvar)
    }
    If you can talk, you can sing, if you can walk, you can dance!!

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1) don't specify language for onmousedown's

    2) Try putting some alerts in the function to see where it's going through the logic - and what it's doing.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •