• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1531
  • Last Modified:

How do I get the mouse position from an iframe?

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

1 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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now