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

How do I get the mouse position from an iframe?

Hi,
How do I get the mouse position from an iframe.
i.e.
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?

Thanks
Jamie
<html>
<head>
<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
   $(document).click(function(e){
      alert(e.pageX +', '+ e.pageY);
   }); 
})
</script>
<body>
 
 
<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>
</div>
</body>
</html>

Open in new window

0
jamie_lynn
Asked:
jamie_lynn
1 Solution
 
prokvkCommented:
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 () {
        $(this.contentDocument).find('body').click(function(e){
            alert(e.pageX +', '+ e.pageY);
        });
    });

Open in new window

0
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