Solved

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

Posted on 2004-08-03
6
720 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
href return to normal window 5 32
DataTable column sorting incorrectly 2 22
How do i use the await event in php echo 5 19
sort Multi-dimensional array 6 19
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

730 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