How do I get the mouse position from an iframe?

Posted on 2009-04-29
Last Modified: 2012-05-06
How do I get the mouse position from an iframe.
In the example html, if you click anywhere other than the calendar, it will alert the mouse position.  How can I get the mouse position inside the calendar?



<script type="text/javascript" src=""></script>

<script type="text/javascript">



      alert(e.pageX +', '+ e.pageY);





<div id="google_calendar">

	<iframe src="" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>




Open in new window

Question by:jamie_lynn
    1 Comment
    LVL 5

    Accepted Solution

    I will paste some code for you that does the trick. But there's a problem. It works for iframes in general, but won't work with Google Calendar since it does not propagate events to the app. Here's the general code, you can try it with some custom iframe:

    $('iframe').load(function () {
                alert(e.pageX +', '+ e.pageY);

    Open in new window


    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Join & Write a Comment

    Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
    What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now