473,657 Members | 2,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Jul 20 '05 #1
4 13945
laurie wrote on 08 feb 2004 in comp.lang.javas cript:
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?


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

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2
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." <ex************ **@interxnl.net > wrote in message news:Xn******** ************@19 4.109.133.29...
laurie wrote on 08 feb 2004 in comp.lang.javas cript:
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?


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

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

Jul 20 '05 #3
"laurie" <la****@hotmail .com> wrote in
news:aW******** **********@news fep4-glfd.server.ntl i.net:
I believe there should be a . after the document, but this didn't work
either.


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
Jul 20 '05 #4
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" <dy********@SPA Mpoczta.fm> wrote in message news:Xn******** *************** ******@127.0.0. 1...
"laurie" <la****@hotmail .com> wrote in
news:aW******** **********@news fep4-glfd.server.ntl i.net:
I believe there should be a . after the document, but this didn't work
either.


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

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2272
by: Richard | last post by:
I know I can have like <a href="#" onclick="dothis" onmouseover="dothat"> But how do you properly code two mouseover's in one statement? <a href="#" onmousever="dothis" onmouseover="dothat"> As an example of use: Column A holds menu items. When a mouse over is performed, two actions take place instead of one. Action one sends an image to a division in column B, action two sends text to another division in column B.
7
3335
by: windandwaves | last post by:
Hi Gurus I am trying to make this rather complicated maps with an a huge number of mouseovers and the like. I want to set up a function that OnMouseDown swaps the OnMouseOver and OnMouseOut for the same element. E.g. <A HREF="#" OnMouseOver="A(); return true" OnMouseOut"B(); return true;"
2
6546
by: news.west.cox.net | last post by:
I have been writing a practice sliding div navigation script. I am finding myself in the position where I need to force a div into showing the hover behavior defined in css. So my question is this. If I have two divs, is there a way to make the second div display its onmouseover behavior when the mouse is over div 1?
3
3941
by: drjackk | last post by:
Hello, I'm trying to change the onmouseover event dynamically. This sets-up the initial onmouseover event: <a href="home.html"> <img border="0" id="img22" src="images/home1.jpg" height="15" width="85" alt="Home" onmouseover="FP_swapImg(1,0,/*id*/'img22',/*url*/'images/home2.jpg')"</a>
2
2723
by: MrCode2k | last post by:
Hello, Trying to do: I just want a table that I can scroll and that has fixed headers. Problem: I got it to work but when I added the onmouseover event it didn't work anymore. Replicate-Problem: Scrolldown the textbox and put the mouse over a row.
7
2791
by: MrCode2k | last post by:
Hello, Trying to do: I just want a table that I can scroll and that has fixed headers. Problem: I got it to work but when I added the onmouseover event it didn't work anymore. Replicate-Problem: Scrolldown the textbox and put the mouse over a row.
2
3347
by: Justin Rowe | last post by:
I'm attempting to design a site with alot of dynamic content and intractability, however I've hit a snag when it comes to the function of the onMouseOver and onMouseOut events. Using a bit of code from QuirksMode to grab the location of the mouse, I've built a tooltip function to show a tooltip to the user depicting the target of a link, the problem is when you mouse over the box that the tooltip function is attatched to the tooltip...
1
18846
by: den2005 | last post by:
Hi everybody, I am confused and still looking why this codes is not working. Can anyone notice or know why this code is not working? Thanks in advance. Code working: <form id="form1" runat="server"> <div> &nbsp;</div> <div>
1
1619
by: find clausen | last post by:
:-) Is that possible, something like: <div onMouseover ........ then the div should scroll up/down to the center of the VP ... but using a function()
0
8395
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8826
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7330
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6166
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.