473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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.onmousemove 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 1719
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="javascript">
var HOOVER_BAR = "HOOVER_BAR";
function showHooverBox(x,y) {
if(!hooverBarVisible) {
var hoover = document.getElementById(HOOVER_BAR);
hoover.innerHTML = "<iframe src=\"details.html?x=" + + "&y=" + y + "\" width=\"200\" heigth=\"200\" scrolling=\"no\"></iframe>";
hoover.style.display = "block";
hoover.style.position = "absolute";
hoover.style.left = x;
hoover.style.top = y;
}
hooverBarVisible = true;
}
function hideHooverBox() {
if(hooverBarVisible) {
var hoover = document.getElementById(HOOVER_BAR);
hoover.style.display = "none";
}
hooverBarVisible = 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 mouseHooverCheck() {
if(current_xpos && current_ypos
&& current_xpos == last_xpos
&& current_ypos == last_ypos)
{
showHooverBox(current_xpos, current_ypos);
}
last_xpos = current_xpos;
last_ypos = current_ypos;
}
// attach the function to the mouse movement
document.onmousemove = mouseMove;
// callback is invoked after 0.5 seconds
window.setInterval(mouseHooverCheck, 500);
// add div, so we can put information in it, when needed
var hooverBarVisible = false;
var hoover = document.createElement("div");
hoover.id = HOOVER_BAR;
hoover.innerText = "[This text has to replaced by code from a certain url]";
hoover.style.display = "none";
document.body.appendChild(hoover);
</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="javascript">
var HOOVER_BAR = "HOOVER_BAR";
function showHooverBox(x,y) {
if(!hooverBarVisible) {
var hoover = document.getElementById(HOOVER_BAR);
hoover.innerHTML = "<iframe src=\"details.html?x=" + + "&y=" + y + "\" width=\"200\" heigth=\"200\" scrolling=\"no\"></iframe>";
hoover.style.display = "block";
hoover.style.position = "absolute";
hoover.style.left = x;
hoover.style.top = y;
}
hooverBarVisible = true;
}
function hideHooverBox() {
if(hooverBarVisible) {
var hoover = document.getElementById(HOOVER_BAR);
hoover.style.display = "none";
}
hooverBarVisible = 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 mouseHooverCheck() {
if(current_xpos && current_ypos
&& current_xpos == last_xpos
&& current_ypos == last_ypos)
{
showHooverBox(current_xpos, current_ypos);
}
last_xpos = current_xpos;
last_ypos = current_ypos;
}
// attach the function to the mouse movement
document.onmousemove = mouseMove;
// callback is invoked after 0.5 seconds
window.setInterval(mouseHooverCheck, 500);
// add div, so we can put information in it, when needed
var hooverBarVisible = false;
var hoover = document.createElement("div");
hoover.id = HOOVER_BAR;
hoover.innerText = "[This text has to replaced by code from a certain url]";
hoover.style.display = "none";
document.body.appendChild(hoover);
</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="javascript">
var HOOVER_BAR = "HOOVER_BAR";
function showHooverBox(x,y) {
if(!hooverBarVisible) {
var hoover = document.getElementById(HOOVER_BAR);
hoover.style.display = "block";
hoover.style.position = "absolute";
hoover.style.borderWidth = "1px";
hoover.style.borderStyle = "solid";
hoover.style.backgroundColor = "#ffffbb";
hoover.style.left = x;
hoover.style.top = y;
// retrieve the dynamic content
var oDom = Sarissa.getDomDocument();
oDom.async = false;
oDom.load("details.aspx?x=" + x + "&y=" + y);
// alert(oDom.xml);
hoover.innerHTML = oDom.xml;
}
hooverBarVisible = true;
}
function hideHooverBox() {
if(hooverBarVisible) {
var hoover = document.getElementById(HOOVER_BAR);
hoover.style.display = "none";
}
hooverBarVisible = 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 mouseHooverCheck() {
if(current_xpos && current_ypos
&& current_xpos == last_xpos
&& current_ypos == last_ypos)
{
showHooverBox(current_xpos, current_ypos);
}
last_xpos = current_xpos;
last_ypos = current_ypos;
}
// attach the function to the mouse movement
document.onmousemove = mouseMove;
// callback is invoked after 0.5 seconds
window.setInterval(mouseHooverCheck, 500);
// add div, so we can put information in it, when needed
var hooverBarVisible = false;
var hoover = document.createElement("div");
hoover.id = HOOVER_BAR;
hoover.innerText = "[This text has to replaced by code from a certain
url]";
hoover.style.display = "none";
document.body.appendChild(hoover);
</script>
</html>
Jul 23 '05 #5

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

Similar topics

1
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...
3
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....
3
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...
1
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...
3
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...
1
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...
2
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...
5
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...
33
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.