How to get mouse event to work over the iframe??

I've been working on it all day with no luck then I figured that I need help.  What I have here is an mouse event that would work outside of the iframe but not over it.  I am wondering if it is possible to have a mouse event that can detect the mouse position either over or inside of the iframe and get a fix on it or something.   Whatever it it, I'll accept your wild idea on making this possible.

Who is Participating?
ZvonkoConnect With a Mentor Systems architectCommented:
How about this:

var msgDiv;
function moveMouse(){
  e = window.frames.myFrame.event;
  msgDiv.innerHTML = e.x+":"+e.y;
function init(){
  msgDiv = document.getElementById("mPos");
<div id="mPos"></div>
<iframe name="myFrame" src="mypage.htm" onLoad="init()"></iframe>

ZylochConnect With a Mentor Commented:
Which mouse event are you talking about?

onmousemove on the main page doesn't work on iframe. If you want the mouse position over the iframe compared to the whole screen, put this code in the <body> tag of the iframe:

<body onmousemove="alert(event.screenX+','+event.screenY);">

Then, in your main page with the iframe, have the same code in the <body>. This should definitely work for both over iframe and over main page, although you'd probably want to store the value into a variable instead of alerting (if you get stuck in an alert loop, move you mouse off the window. Press Enter, then do AltF4)

fletchsodAuthor Commented:
Yes, it had to do with the onmousemove events.  Both examples are good enough for me.  I can take it from there.  

Thanks, FletchSOD
fletchsodAuthor Commented:
Rat!  I'm trying to pick one as accept answer with 125 points and the other as assist answer with 125 points also.  Where's that community forum where I can ask the administrator to fix it for me??  Thanks. Scott
ZvonkoSystems architectCommented:
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.

All Courses

From novice to tech pro — start learning today.