Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8697523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:32:51+00:00 2026-06-13T01:32:51+00:00

I have an iframe inside of a parent window, with both the iframe src

  • 0

I have an iframe inside of a parent window, with both the iframe src and the parent located in the same domain. In order to keep the iframe document clear of Javascript I want to be able to use a function in the parent window to get the the mouse position inside the iframe.

My attempts at this so far have included:

<iframe id="iframe1" src="test.html" style="position:relative; width:500px; height:500px"></iframe>
<div id="result" style="border:1px solid black"></div>

<script>
$(document).bind("mousemove", function(e){
    $("#result").html("x:" + e.pageX + ", y:" + e.pageY);
});
    
$("#iframe1").contents().find(document).bind("mousemove", function(e){
$("#result", window.parent.document).html("x:" + e.pageX + ", y:" + e.pageY);
});
</script>

The first mousemove event works correctly displaying the mouse position in the results div, but the second event (which I was attempting to bind to the iframe document) gives no response.​

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:32:52+00:00Added an answer on June 13, 2026 at 1:32 am

    This works, except for the permissions part.

    JS:

    $(document).bind("mousemove", function(e) {
        $("#result").html("x:" + e.pageX + ", y:" + e.pageY);
    });
    
    $($("#iframe1").contents()[0], window).bind("mousemove", function(e) {
        $("#result").html("x:" + (e.pageX) + ", y:" + e.pageY);
    });
    

    The problem was with .find(). I simply used the first index on the array returned by content, because an iframe is supposed to contain nothing but a document.

    Updated with a better example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a parent document with an embedded iframe. Inside the iframe I have
I have a page with iframe. Content inside iframe does window.parent.resizeTo calls (or something
I have this code inside a iframe: window.addEventListener('message', function(e){ if(e.data == 'test') console.log(e); },
I have some javascript inside an iframe that sends the height of the iframe
How to exit from iframe? I have a pages called Master.aspx , Parent.aspx (inside
I have an iFrame inside my document, which at one point triggers a custom
I have an Iframe inside of a page that has the src set to
I have parent page index.php and inside it i have iframe like below <div
I have a very long iframe inside my parent page. When you reload or
I have a page in html (parent page) that have inside an iframe. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.