473,887 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

No mousemovement for a certain amount of time

Hello,

I want to make a hooverbox, which is shown when the mousepointer is not
moved for a amount of time.

When the hooverbox is shown, i will do a server request to retrieve the
information for the hooverbox.

I was thinking of using document.onmous emove and a infinit running while
loop comparing the mouse positions. Is this the way to solve it?
(pointers/samples are welcome ;-) )

Eduard Witteveen
Jul 23 '05 #1
4 1762
Eduard,

You can try looking into using setInterval function. When setInterval
calls the function, you could grab the coordinates of the mouse and
compare it with the previous x-y coordinates and see if there was any
change. If there isn't then you can do a server request otherwise
don't.

Jul 23 '05 #2
web.dev wrote:
You can try looking into using setInterval function. When setInterval
calls the function, you could grab the coordinates of the mouse and
compare it with the previous x-y coordinates and see if there was any
change. If there isn't then you can do a server request otherwise
don't.
Thank you very much, i got every thing working as you can see in the
sample below.

But i now have the problem that inserting the iframe into the page
triggers a mouseMove,... And since the load is finished after the
showHooverBox method, i cant stop it from happening,.. Any suggestions?
(i was thinking of not using a iframe, but putting the content of the
details.html hard in the the dhtml structure, but i dont know how to
issue a request from javascript_
<html>
<head>
</head>
<body>
</body>
<script language="javas cript">
var HOOVER_BAR = "HOOVER_BAR ";
function showHooverBox(x ,y) {
if(!hooverBarVi sible) {
var hoover = document.getEle mentById(HOOVER _BAR);
hoover.innerHTM L = "<iframe src=\"details.h tml?x=" + + "&y=" + y + "\" width=\"200\" heigth=\"200\" scrolling=\"no\ "></iframe>";
hoover.style.di splay = "block";
hoover.style.po sition = "absolute";
hoover.style.le ft = x;
hoover.style.to p = y;
}
hooverBarVisibl e = true;
}
function hideHooverBox() {
if(hooverBarVis ible) {
var hoover = document.getEle mentById(HOOVER _BAR);
hoover.style.di splay = "none";
}
hooverBarVisibl e = false;
}
var last_xpos;
var last_ypos;
var current_xpos;
var current_ypos;
// update the last movement
function mouseMove(e) {
current_xpos = event.x;
current_ypos = event.y;
hideHooverBox() ;
}
function mouseHooverChec k() {
if(current_xpos && current_ypos
&& current_xpos == last_xpos
&& current_ypos == last_ypos)
{
showHooverBox(c urrent_xpos, current_ypos);
}
last_xpos = current_xpos;
last_ypos = current_ypos;
}
// attach the function to the mouse movement
document.onmous emove = mouseMove;
// callback is invoked after 0.5 seconds
window.setInter val(mouseHoover Check, 500);
// add div, so we can put information in it, when needed
var hooverBarVisibl e = false;
var hoover = document.create Element("div");
hoover.id = HOOVER_BAR;
hoover.innerTex t = "[This text has to replaced by code from a certain url]";
hoover.style.di splay = "none";
document.body.a ppendChild(hoov er);
</script>
</html>



Jul 23 '05 #3
web.dev wrote:
You can try looking into using setInterval function. When setInterval
calls the function, you could grab the coordinates of the mouse and
compare it with the previous x-y coordinates and see if there was any
change. If there isn't then you can do a server request otherwise
don't.
Thank you very much, i got every thing working as you can see in the
sample below.

But i now have the problem that inserting the iframe into the page
triggers a mouseMove,... And since the load is finished after the
showHooverBox method, i cant stop it from happening,.. Any suggestions?
(i was thinking of not using a iframe, but putting the content of the
details.html hard in the the dhtml structure, but i dont know how to
issue a request from javascript_
<html>
<head>
</head>
<body>
</body>
<script language="javas cript">
var HOOVER_BAR = "HOOVER_BAR ";
function showHooverBox(x ,y) {
if(!hooverBarVi sible) {
var hoover = document.getEle mentById(HOOVER _BAR);
hoover.innerHTM L = "<iframe src=\"details.h tml?x=" + + "&y=" + y + "\" width=\"200\" heigth=\"200\" scrolling=\"no\ "></iframe>";
hoover.style.di splay = "block";
hoover.style.po sition = "absolute";
hoover.style.le ft = x;
hoover.style.to p = y;
}
hooverBarVisibl e = true;
}
function hideHooverBox() {
if(hooverBarVis ible) {
var hoover = document.getEle mentById(HOOVER _BAR);
hoover.style.di splay = "none";
}
hooverBarVisibl e = false;
}
var last_xpos;
var last_ypos;
var current_xpos;
var current_ypos;
// update the last movement
function mouseMove(e) {
current_xpos = event.x;
current_ypos = event.y;
hideHooverBox() ;
}
function mouseHooverChec k() {
if(current_xpos && current_ypos
&& current_xpos == last_xpos
&& current_ypos == last_ypos)
{
showHooverBox(c urrent_xpos, current_ypos);
}
last_xpos = current_xpos;
last_ypos = current_ypos;
}
// attach the function to the mouse movement
document.onmous emove = mouseMove;
// callback is invoked after 0.5 seconds
window.setInter val(mouseHoover Check, 500);
// add div, so we can put information in it, when needed
var hooverBarVisibl e = false;
var hoover = document.create Element("div");
hoover.id = HOOVER_BAR;
hoover.innerTex t = "[This text has to replaced by code from a certain url]";
hoover.style.di splay = "none";
document.body.a ppendChild(hoov er);
</script>
</html>



Jul 23 '05 #4
Eduard Witteveen wrote:
But i now have the problem that inserting the iframe into the page
triggers a mouseMove,... And since the load is finished after the
showHooverBox method, i cant stop it from happening,.. Any suggestions?
(i was thinking of not using a iframe, but putting the content of the
details.html hard in the the dhtml structure, but i dont know how to
issue a request from javascript

I fixed this by using the following code:

<html>
<head>
<script type="text/javascript" src="sarissa/sarissa.js"></script>
</head>
<body>
</body>
<script language="javas cript">
var HOOVER_BAR = "HOOVER_BAR ";
function showHooverBox(x ,y) {
if(!hooverBarVi sible) {
var hoover = document.getEle mentById(HOOVER _BAR);
hoover.style.di splay = "block";
hoover.style.po sition = "absolute";
hoover.style.bo rderWidth = "1px";
hoover.style.bo rderStyle = "solid";
hoover.style.ba ckgroundColor = "#ffffbb";
hoover.style.le ft = x;
hoover.style.to p = y;
// retrieve the dynamic content
var oDom = Sarissa.getDomD ocument();
oDom.async = false;
oDom.load("deta ils.aspx?x=" + x + "&y=" + y);
// alert(oDom.xml) ;
hoover.innerHTM L = oDom.xml;
}
hooverBarVisibl e = true;
}
function hideHooverBox() {
if(hooverBarVis ible) {
var hoover = document.getEle mentById(HOOVER _BAR);
hoover.style.di splay = "none";
}
hooverBarVisibl e = false;
}
var last_xpos;
var last_ypos;
var current_xpos;
var current_ypos;
// update the last movement
function mouseMove(e) {
current_xpos = event.x;
current_ypos = event.y;
hideHooverBox() ;
}
function mouseHooverChec k() {
if(current_xpos && current_ypos
&& current_xpos == last_xpos
&& current_ypos == last_ypos)
{
showHooverBox(c urrent_xpos, current_ypos);
}
last_xpos = current_xpos;
last_ypos = current_ypos;
}
// attach the function to the mouse movement
document.onmous emove = mouseMove;
// callback is invoked after 0.5 seconds
window.setInter val(mouseHoover Check, 500);
// add div, so we can put information in it, when needed
var hooverBarVisibl e = false;
var hoover = document.create Element("div");
hoover.id = HOOVER_BAR;
hoover.innerTex t = "[This text has to replaced by code from a certain
url]";
hoover.style.di splay = "none";
document.body.a ppendChild(hoov er);
</script>
</html>
Jul 23 '05 #5

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

Similar topics

1
2841
by: Pif Paf | last post by:
I have a process, and my process wants to wait for input but only for a certain amount of time. The input might be coming from a Python file object (created with popen) or a TCP socket. What I want is something like: s = getTimedInput(source, maxDelay) where: source = the source of the input
3
1676
by: Matt | last post by:
Are there any settings to make a page invisible to the user until certain time? For example, I want mypage.html is invisible to the user until 12:00am. But mypage.html is already in the IIS server. any ideas? thanks!
3
1706
by: Mike | last post by:
I have a view that will return say 5000 records when I do a simple select query on that view like. select * from vw_test_view How can I set up my query to only return a certain # of records, say the first 300?
1
866
by: Joe McIntier | last post by:
I am trying to sum the amounts attributes of a transaction element but only for transaction elements where the SaleType attribute is equal to SALE XML Snippet: <Root> <Transaction Amount="1.23" SaleType="SALE"> <OptionalElelment/>
3
1820
by: Chanchito | last post by:
hi there, I am seeking some guidance in regards to creating a query. I would like to be able to have the query display records that have had a certain amount of time pass since the time that is listed a particular field of the record. There is a field labeld DispTime. This field is updated with the current time whenever data is typed into another field on the current record. What I am trying to figure out is how to create a query that...
1
2664
by: Jack Wright | last post by:
Dear All, I have observed that if I call a synchronous WebService from my aspx page then even if I set oProxy.TimeOut = 1000, the WebService thread execution is still running... Since my WebService might run a big query that a client has written, it eventually recycles my workerprocess... How to I abort the WebService execution I tried to set httpRuntime executionTimeout in my Web.Config and Machine.config... <httpRuntime...
2
1418
by: Jim | last post by:
I know about and expect the first time an asp.net is viewed that the JIT compiler willc ompile the page and hence the slow response time for the page, but after a certain amount of time my asp.net is very slow to load a page again and then everything is fine again - why is this? Cheers Jim
5
4131
by: raybakk | last post by:
Hi there. If I make a function in c (I acually use gnu right now), is there any way to find out how many clocksycluses that function takes? If I divide some numbers etc Var1 = Var2/Var3, is it a fix amount of clocksycluses that is been used for that division, or does it varies? Raymond
33
5584
by: desktop | last post by:
In the C++ standard sec 23.1.2 table 69 it says that erase(q) where q is a pointer to an element can be done in amortized constant time. I guess that is not worst case since std::set is practically a red-black tree where insert/delete takes O(lg n) time. Or are there some other explanation for this complexity?
0
10770
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
10875
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
10432
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...
1
7988
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
7141
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
5809
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...
0
6011
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4632
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
4238
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.