Solved

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

Posted on 2004-08-03
6
674 Views
Last Modified: 2008-03-17
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.

Thanks,
 FletchSOD
0
Comment
Question by:fletchsod
  • 2
  • 2
6 Comments
 
LVL 36

Assisted Solution

by:Zyloch
Zyloch earned 125 total points
ID: 11710542
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)

Regards,
${Zyloch}
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 125 total points
ID: 11710585
How about this:

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


0
 

Author Comment

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

Thanks, FletchSOD
0
 

Author Comment

by:fletchsod
ID: 11715866
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
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11716416
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

932 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

12 Experts available now in Live!

Get 1:1 Help Now