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

Zoom page -> Mouse position wrong?

Hi,

I have a function on my page to zoom in (for people who have not very good
eyes for example):

var zoom_factor=100;
function zoom(how)
{
var bodyStyle = document.body.style;
zoom_factor = (how)?100:110;
zoomed = bodyStyle.zoom;
if ((zoomed)&&(zoom_factor!=100))
zoom_factor=parseInt(zoomed)*parseInt(zoom_factor)/100;
bodyStyle.setAttribute('zoom', parseInt(zoom_factor)+'%');
}
I also have a function to locate the mouse cursor:

var x, y;
function TraceMouse(e)
{
x = (document.all) ? document.body.scrollLeft + event.clientX : e.pageX;
y = (document.all) ? document.body.scrollTop + event.clientY : e.pageY;
flag = 1;
}
if (!document.all)
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = TraceMouse;
Now I want to write some menu on the place where the mouse is oncontextmenu.
But when the page is zoomed in, the menu is placed more down than usual.

The page (just a page I make to test what is possible with javascript):
http://www.djwice.com/contextmenu.html
The script:
http://www.djwice.com/contextmenu/contextmenu.js

If anyone has ideas why it goes wrong, please let me know.
Thanks,
Wouter

Jul 20 '05 #1
1 5500
Problem solved:

If one zooms the mouse position is the location on the not zoomed page.
But the placement pixels are the position on the new page.
So one need to correct for the zoom_factor.

Wouter

"DJ WIce" <co*********@djwice.com> wrote in message
news:bu**********@news.tudelft.nl...
: Hi,
:
: I have a function on my page to zoom in (for people who have not very good
: eyes for example):
:
: var zoom_factor=100;
: function zoom(how)
: {
: var bodyStyle = document.body.style;
: zoom_factor = (how)?100:110;
: zoomed = bodyStyle.zoom;
: if ((zoomed)&&(zoom_factor!=100))
: zoom_factor=parseInt(zoomed)*parseInt(zoom_factor)/100;
: bodyStyle.setAttribute('zoom', parseInt(zoom_factor)+'%');
: }
:
:
: I also have a function to locate the mouse cursor:
:
: var x, y;
: function TraceMouse(e)
: {
: x = (document.all) ? document.body.scrollLeft + event.clientX : e.pageX;
: y = (document.all) ? document.body.scrollTop + event.clientY : e.pageY;
: flag = 1;
: }
: if (!document.all)
: document.captureEvents(Event.MOUSEMOVE);
: document.onmousemove = TraceMouse;
:
:
: Now I want to write some menu on the place where the mouse is
oncontextmenu.
: But when the page is zoomed in, the menu is placed more down than usual.
:
: The page (just a page I make to test what is possible with javascript):
: http://www.djwice.com/contextmenu.html
: The script:
: http://www.djwice.com/contextmenu/contextmenu.js
:
: If anyone has ideas why it goes wrong, please let me know.
: Thanks,
: Wouter
:
:
:
Jul 20 '05 #2

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

Similar topics

4
by: stef | last post by:
Hello: I am trying to design a web page whose graphics content would change according to the "text Zoom" settings of the user. (Basically the goal is to use mathematical symbols that...
0
by: Francis Parsons | last post by:
Hi! I'm doubtful there's a workaround for this problem, but it's worth a shot. I'm using IE's (css) "zoom" property to zoom the body of a document (in conjunction with persistance so the...
0
by: davide rocchelli | last post by:
I have found a probable bug when you draw with GDI. Look this simple code Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint ...
3
by: Keith G Hicks | last post by:
In MS Access image controls there's a property setting for "Size Mode" --> Clip, Zoom or Stretch. I don't see any similar property in an asp image control. When I have an image on a page, it seems...
9
by: patrick j | last post by:
Hi I've just discovered that IE 7 messes up horizontal lists. I've done a bit of searching the web but a solution has not sprung forth from this searching. Below is a url with a horizontal...
3
by: jnag | last post by:
I am trying to implement font changer, where I have links on the banner of the site and when the user clicks on the links, the font size of the page has to change. I tried...
2
by: IanTrent | last post by:
On my website, I have an absolute positioned menu that moves with the page when the user scrolls. It determines its place on the page by referencing document.body.clientHeight or...
1
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.