Onmouseover to scroll DIV?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laurie

    #1

    Onmouseover to scroll DIV?

    Hi.
    I have a DIV section that has many thumbnail images inside it. I have a DIV so all images can fit in a row and the horizontal
    scroll bar is used to move the thumbnails from left to right.

    Does anyone know any code to have the DIV scroll from left to right when I use an onmouseover on two images either side of the
    DIV?

    Thanks

    Laurie

  • Evertjan.

    #2
    Re: Onmouseover to scroll DIV?

    laurie wrote on 08 feb 2004 in comp.lang.javas cript:
    [color=blue]
    > I have a DIV section that has many thumbnail images inside it. I have
    > a DIV so all images can fit in a row and the horizontal scroll bar is
    > used to move the thumbnails from left to right.
    >
    > Does anyone know any code to have the DIV scroll from left to right
    > when I use an onmouseover on two images either side of the DIV?
    >[/color]

    onmouseover="do cument,getEleme ntById('myDiv') .scrollBy(200,0 )"

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • laurie

      #3
      Re: Onmouseover to scroll DIV?

      Thanks, but I cant get this to work.

      I believe there should be a . after the document, but this didn't work either.

      Laurie

      "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message news:Xns9489E3D 18D362eejj99@19 4.109.133.29...
      laurie wrote on 08 feb 2004 in comp.lang.javas cript:
      [color=blue]
      > I have a DIV section that has many thumbnail images inside it. I have
      > a DIV so all images can fit in a row and the horizontal scroll bar is
      > used to move the thumbnails from left to right.
      >
      > Does anyone know any code to have the DIV scroll from left to right
      > when I use an onmouseover on two images either side of the DIV?
      >[/color]

      onmouseover="do cument,getEleme ntById('myDiv') .scrollBy(200,0 )"

      --
      Evertjan.
      The Netherlands.
      (Please change the x'es to dots in my emailaddress)

      Comment

      • Mr Dygi

        #4
        Re: Onmouseover to scroll DIV?

        "laurie" <lawr_1@hotmail .com> wrote in
        news:aWyVb.1979 $cb7.13862@news fep4-glfd.server.ntl i.net:
        [color=blue]
        > I believe there should be a . after the document, but this didn't work
        > either.[/color]

        Maybe you should put *yours* "DIV name" instead of myDiv. Let us see your
        piece of code.

        --
        pozdr. Dygi [GG 1027078]
        dygimail(at)poc zta(dot)fm

        Comment

        • laurie

          #5
          Re: Onmouseover to scroll DIV?

          I did.
          This is what I tried from the suggestion:

          <div id="myDiv" nowrap class='thumbnai ls'>
          // my code to list thumbnails images.
          </div>

          <img src="right_arro w.gif" onmouseover="do cument.getEleme ntById('myDiv') .scrollBy(200,0 )">



          Since then I have found a much more detailed method, which seems quite complicated. I am on the verge of getting it to work except
          I cant get the following code to work:

          if (direction == "rt" && x_pos > max_posn)
          {
          page.left = (x_pos - (speed));
          }

          Where max_posn is the maximum position to scroll a div layer to then stop. It works if I enter an actual value, but when assigned
          to a variable (and even parseInt() the variable) it doesn't work. I assign it to a variable because the max_posn variable is
          calculated from the number of thumbnails so I cant just put a value in there.

          Here's the full (very long) code. A shorter version would be great.



          <head>
          <SCRIPT LANGUAGE="JavaS cript">
          function horScroll(dir, spd, loop, max_posn)
          {
          max_posn = -1*max_posn; // to produce an integer in case it thinks its a string. I have also used parseInt();
          loop = true;
          direction = "lt";
          speed = 10;
          scrolltimer = null;
          if (document.layer s)
          {
          var page = eval(document.c ontentLayer);
          }
          else
          {
          if (document.getEl ementById)
          {
          var page= eval("document. getElementById( 'contentLayer') .style");
          }
          else
          {
          if (document.all)
          {
          var page = eval(document.a ll.contentLayer .style);
          }
          }
          }
          direction = dir;
          speed = parseInt(spd);
          var x_pos = parseInt(page.l eft);
          if (loop == true)
          {
          if (direction == "rt" && x_pos > max_posn) // THIS DOES NOT WORK WITH max_posn BUT DOES WORK WITH A NUMBER
          {
          page.left = (x_pos - (speed));
          }
          else
          {
          if (direction == "lt" && x_pos < 0)
          {
          page.left = (x_pos + (speed));
          }
          else
          {
          if (direction == "left")
          {
          page.left = 10;
          }
          }
          }
          scrolltimer = setTimeout("hor Scroll(directio n,speed)", 1);
          }
          }

          function stopScroll()
          {
          loop = false;
          clearTimeout(sc rolltimer);
          }

          </script>
          </head>


          <div nowrap class='thumbnai ls'>
          <div id="contentLaye r" style="position :absolute; width:300px; z-index:1; lt: 39px; left: 51px">
          // code to show thumbnails here
          </div>
          </div>


          <div id="scrollmenu " style="position :top;width:200p x;height:30px;z-index:1; lt:400px; left: 40px">
          <table border=1><tr><t d>
          <table>
          <tr>
          <td align=lt>Left</td>
          <td></td>
          <td align=right>Rig ht</td>
          </tr>
          <tr>
          <td colspan=3>
          <a href="#" onMouseOver="ho rScroll('lt','2 5','true', '<? echo $max_pos; ?>')" onMouseOut="sto pScroll()"><<<</a>
          <a href="#" onMouseOver="ho rScroll('lt','5 ','true', '<? echo $max_pos; ?>')" onMouseOut="sto pScroll()"><<</a>
          <a href="#" onMouseOver="ho rScroll('lt','1 ','true', '<? echo $max_pos; ?>')" onMouseOut="sto pScroll()"><</a> |
          <a href="#" onMouseOver="ho rScroll('rt','1 ','true', '<? echo $max_pos; ?>')" onMouseOut="sto pScroll()">></a>
          <a href="#" onMouseOver="ho rScroll('rt','5 ','true', '<? echo $max_pos; ?>')" onMouseOut="sto pScroll()">>></a>
          <a href="#" onMouseOver="ho rScroll('rt','2 5','true', '<? echo $max_pos; ?>')" onMouseOut="sto pScroll()">>>></a>
          </td>
          </tr>
          </table>
          </td></tr></table>
          </div>





          "Mr Dygi" <dygimailNo@SPA Mpoczta.fm> wrote in message news:Xns948AE83 6EFFCdygimailpo cztafm@127.0.0. 1...
          "laurie" <lawr_1@hotmail .com> wrote in
          news:aWyVb.1979 $cb7.13862@news fep4-glfd.server.ntl i.net:
          [color=blue]
          > I believe there should be a . after the document, but this didn't work
          > either.[/color]

          Maybe you should put *yours* "DIV name" instead of myDiv. Let us see your
          piece of code.

          --
          pozdr. Dygi [GG 1027078]
          dygimail(at)poc zta(dot)fm

          Comment

          Working...