I currently have an iframe within my parent page and I was wondering whether it’s possible to capture a onmouseout event to trap when the user clicks or moves outside the iframe border, i.e back onto parent page.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should be able do a document.body.onmouseleave/onmouseout (see edits) in the iframe’s page. Since it bubbles you’ll have to check that it was actually the body that fired the event.
EDIT: My mistake, onmouseleave doesn’t bubble, so the if statement there isn’t necessary. onmouseleave doesn’t work for other browsers, so you should use onmouseout and keep the if statement in since onmouseout does bubble.
if you’re only bothered about IE6, put the following <script> tag into your iframe page’s code (preferably the header).
See the MSDN documentation here