473,734 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

loop mouseover event?

Hello All,

How can you continue the mouseover event while the mouse is still over
an object?
For example:
I put my mouse over a hyperlink and that triggers an object to move
10px to the right.
I want the object to continue moving 10px to the right every 1 second
untill i take my mouse off of the hyperlink.

Any ideas?
Thanks,
Gil

Jun 13 '06 #1
1 2663
giloosh wrote:
Hello All,

How can you continue the mouseover event while the mouse is still over
an object?
For example:
I put my mouse over a hyperlink and that triggers an object to move
10px to the right.
I want the object to continue moving 10px to the right every 1 second
untill i take my mouse off of the hyperlink.
Use mouseover to start the object moving. Have a 'move the object'
function call itself sequentially using setTimeout each 1000ms. Use
mouseout to cancel the timer.

There are a number of different behaviours that can result from the
above depending upon the DOM structure of the particular elements and
whether you cancel bubbling/capture phases of event propigation.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<title>play</title>
<style type="text/css">
body {margin: 0; padding:0;}
#greyDiv {
width: 200px; height: 200px;
background-color: #ddd;
}
#redDiv {
width:3em; height:3em;
border:1px solid red;
position: absolute;
top: 0px; left: 0px;
}
</style>
<div id="greyDiv"
onmouseover="mo veIt.start('red Div');"
onmouseout="mov eIt.stop();"Mouseover me and the red guy will move...

<div id="redDiv">re d div</div>
</div>
<span id="x"></span>
<script type="text/javascript">
var moveIt = (function()
{
var t;
var cursorPos = 'out';
function moveLeft(o){
o.style.left = parseInt(o.styl e.left||'0') + 10 + 'px';
}
return ({
start: function(id){
cursorPos = 'over';
if (!t){
moveIt.run(id);
}
},
run : function(id) {
var obj = document.getEle mentById(id);
if ('over' == cursorPos){
moveLeft(obj);
t = setTimeout('mov eIt.run("'+id+' ")',1000);
} else {
if (t) {
clearTimeout(t) ;
t = false;
}
}
},
stop : function() {
cursorPos = 'out';
}
});
})();
</script>
</html>
--
Rob

Jun 14 '06 #2

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

Similar topics

3
2299
by: Colin Steadman | last post by:
Help! I'm a stupid HTML bod and I dont do Javascript! I have a grey coloured table that displays certain columns in either red, green or orange to give meaning and emphasis to certain data. What I want to do now is setup some kind of javascript event so that when the user mouse's over a row the row changes colour to highlight it. I've discovered however that I can only change the row into one specific colour, and then back again into...
2
3351
by: Alex | last post by:
On my page I have a lot string like this: <span onmouseover="callMe(this)" onmouseout="callMe(null)" >abc1</span> <span onmouseover="callMe(this)" onmouseout="callMe(null)" >abc2</span> <span onmouseover="callMe(this)" onmouseout="callMe(null)" >abc3</span> <span onmouseover="callMe(this)" onmouseout="callMe(null)" >abc4</span> How can I optimize it? Is it possible to move this definition what to do to style/css or some other common...
2
5175
by: Mitch | last post by:
I am hosting a web browser ctl in a container that implements the IDocHostUIHandler interface. I'm using this to control the context menu.This works fine. Then, I added a mouseover event to the document in the documentComplete event handler. When I add this event handler, I loose all other navigation functions in the browser! right click, left click, it's all dead. (The mouseover works though)
2
4486
by: Dariusz Tomon | last post by:
Hi I got task to make my application much more attractive :( First of all I have to add hover (mouseover) effect to several buttons - imagebuttons - I only know manner with Java Script - but it does not work with ASPNET objects. Any ideas? Darek
3
1227
by: petermichaux | last post by:
Hi, Is there a general consenses which is faster? a) a for loop to iterate through n objects stored in an array b) a for-in loop to iterate through n objects stored as properties of an object I'm deciding which storage technique I should use for targets in a dragdrop application. When I move the dragging object I must loop
10
2687
by: jjamjatra | last post by:
I am struggling with a event model handling problem in Javascript that shows up only in Firefox. I have 2 little websites I'd like you to take a look at: http://gis.cbmiweb.com/MexicoExported/default.asp http://gis.cbmiweb.com/MDWmaps/default.asp The issue involves the code behind the "Zoom Box" icon on the "toolbar" near the top of each page. On both pages above, the ZoomBox
2
3031
by: markszlazak | last post by:
I'm a relatively slow response of table cells changing their background color with mouseover/our in IE6 (Win 2K) but the response is fine (fast) in Firefox. Why? The code is below. Sorry about the length. <html> <head> <title>Rapid Blocking Interface</title> <style> .calendar {
2
2286
by: markszlazak | last post by:
Could someone check out the following code and please help me understand the problem and fix it. It seems like some events are not firing when my mouse moves over the table cells to quickly causing some table cells to stay yellow when you move out of them instead of going back to blue. (Note that I'm using DIV's inside this table because the lightyellow one will contain an image that will be mousedowned on to start a cell selection mode...
0
8946
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
8777
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9452
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
9310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6033
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
4551
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3262
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
2729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.