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

iframe relative mouse position

Hi,
I have an iframe with some javascipt that gets the mouse x and y
position like this:
//inside the iframe's onmousemove call back funciton
xMousePos = window.event.clientX + document.body.scrollLeft;
yMousePos = window.event.clientY + document.body.scrollTop;

This gets the x and y position inside the iframe. But what I want is
the x and y position of the parent window, not the screen like
screenX. Is there any easy way to get parentX and parentY or to get
the offset x and y of the iframe relitive to the parent from inside
the iframe?
thanks in advance,
mike
Jul 20 '05 #1
2 16440
The way I've done this in the past (if memory serves) is to find the element containing the IFrame and then percolate
up using .offsetParent

Csaba Gabor

"madmike" <mi***@cs.cmu.edu> wrote in message news:cb**************************@posting.google.c om...
Hi,
I have an iframe with some javascipt that gets the mouse x and y
position like this:
//inside the iframe's onmousemove call back funciton
xMousePos = window.event.clientX + document.body.scrollLeft;
yMousePos = window.event.clientY + document.body.scrollTop;

This gets the x and y position inside the iframe. But what I want is
the x and y position of the parent window, not the screen like
screenX. Is there any easy way to get parentX and parentY or to get
the offset x and y of the iframe relitive to the parent from inside
the iframe?
thanks in advance,
mike

Jul 20 '05 #2
this worked for me.

// get the position relitive to the entire window
var el =parent.frames[FRAME_NAME].frameElement.offsetParent;
var x = 0, y = 0;

while (el)
{
x += el.offsetLeft;
y += el.offsetTop;
el = el.offsetParent;
}
Jul 20 '05 #3

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

Similar topics

1
by: ajay | last post by:
I have following code for a slide menu but i twiked it to work for a single level menu. Open it in a Browser to get a clear picture. I have 2 Qs 1) How to make first entry as non-link. i.e i...
8
by: Asad | last post by:
Hi, I am basically trying to accomplish drop down menus for navigation on a site. And I'm pretty much done except I am having one problem. The z-index is not working with relative positioning! ...
3
by: coolsti | last post by:
I need some help here. I am making an application which allows a user to look at a series of picture files one at a time, and enter the outcome of various visual tests to a database. The...
7
by: Patrick.O.Ige | last post by:
Can i use Frameset in ASP.NET?What are other options I have a question :- I have an asp.net page and i'm using TreeView control as links The links are on the left side of the page inside a iframe!...
1
by: milbrand | last post by:
I have an IFrame: <IFRAME id="BIssues" title="issues" src="BIssues.aspx" frameBorder="no"style="position:absolute;width:100%;height: 150px;border:0px"> In this iframe I have onmouseover that...
0
by: dimepiece18 | last post by:
On our Intranet homepage, I have a layer with an iframe contained in it. The iframe is linked to an html document that is stored in our Content Library system. You have to be authorized to view the...
1
by: k.roemke | last post by:
Hello! After a longer time I want to do some javascript again. Task: set content of an iframe to the origin page if the mouse is not moved Problem: <iframe onmousemove="resetCounter();return...
6
by: deknoopjes | last post by:
I want to display a specific area of an external website using iFrames. A year ago I created such code successfully, but lost this code due to a crashed computer. Googling for any solutions did not...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
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
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...

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.