Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How do I get the mouse position from an iframe?

Posted on 2009-04-29
Medium Priority
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="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
<script type="text/javascript">
      alert(e.pageX +', '+ e.pageY);
<div id="google_calendar">
	<iframe src="http://www.google.com/calendar/embed?src=usa%40holiday.calendar.google.com&ctz=America/Los_Angeles" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>

Open in new window

Question by:jamie_lynn
1 Comment

Accepted Solution

prokvk earned 2000 total points
ID: 24281215
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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…
Suggested Courses
Course of the Month11 days, 2 hours left to enroll

571 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