?
Solved

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

Posted on 2004-08-03
6
Medium Priority
?
791 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 36

Assisted Solution

by:Zyloch
Zyloch earned 500 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 500 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…
Suggested Courses

752 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