473,320 Members | 1,990 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,320 software developers and data experts.

Javascript and Style coordinates Question

I have a little <Div> following the Mousecursor on mousemove event of
page...

refObject.style.top = event.y
refObject.style.left = event.x

It works fine... BUT when there's a lot more on the page (a growing
Datagrid) which make page need to scroll and you scroll down... the
coordinates does not match the mouscursor anymore since the Top value is not
getting as big as it needs from the event.y property

So how do I calculate how much I have to add to the top style value or can I
somehow convert the event.y to the actualy value from the Top of the page?

best Regards/

Lars Netzel


Nov 19 '05 #1
2 957
Give this a shot:
document.body.scrollTop + event.y;
If you are using flow layout, you may want to try this:
document.body.scrollTop + event.clientY;
"Lars Netzel" <ui****@adf.se> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
I have a little <Div> following the Mousecursor on mousemove event of
page...

refObject.style.top = event.y
refObject.style.left = event.x

It works fine... BUT when there's a lot more on the page (a growing
Datagrid) which make page need to scroll and you scroll down... the
coordinates does not match the mouscursor anymore since the Top value is
not getting as big as it needs from the event.y property

So how do I calculate how much I have to add to the top style value or can
I somehow convert the event.y to the actualy value from the Top of the
page?

best Regards/

Lars Netzel



Nov 19 '05 #2
Yes, thank you! I did get that tip before you wrote this but it was the
solution that worked. Thank you!

/Lars
"Chris Botha" <ch***********@AThotmail.com> wrote in message
news:eN**************@TK2MSFTNGP12.phx.gbl...
Give this a shot:
document.body.scrollTop + event.y;
If you are using flow layout, you may want to try this:
document.body.scrollTop + event.clientY;
"Lars Netzel" <ui****@adf.se> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
I have a little <Div> following the Mousecursor on mousemove event of
page...

refObject.style.top = event.y
refObject.style.left = event.x

It works fine... BUT when there's a lot more on the page (a growing
Datagrid) which make page need to scroll and you scroll down... the
coordinates does not match the mouscursor anymore since the Top value is
not getting as big as it needs from the event.y property

So how do I calculate how much I have to add to the top style value or
can I somehow convert the event.y to the actualy value from the Top of
the page?

best Regards/

Lars Netzel




Nov 19 '05 #3

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

Similar topics

6
by: R | last post by:
Hello everybody! I'm newbie to JavaScript and I have a basic question. I have X and Y coordinates of A and B points. How can I draw a line connecting A and B? thanks in advance cheers
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
3
by: Harch84 | last post by:
Hi I am using a javascript for google maps to geocode two locations and I thin want to retrieve the two coordinates and enter them into a Perl Script. Now I have managed to set up the page with the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.