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

  • SEARCH
  • Home
  • 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 1000547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:31:51+00:00 2026-05-16T07:31:51+00:00

What a mouthful. Basically I have a parent <div> and inside that an <iframe>

  • 0

What a mouthful.

Basically I have a parent <div> and inside that an <iframe>. I need an element inside the iframe to be the handle to drag the parent div. Is this even possible?

I have tried:

$(node).draggable("option","handle",$('iframe',node).contents().find('#handle'));
$(node).draggable("option","handle",$('iframe',node).contents().find('#handle')[0]);

It is targeting the right DOM element but it just won’t drag. It might be possible to overlay a hidden div ontop of the iframe but I have found the iframe takes the event over the div when position is absolute. Strange.

  • 1 1 Answer
  • 1 View
  • 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-05-16T07:31:52+00:00Added an answer on May 16, 2026 at 7:31 am

    I decided to take a stab at this and boy, it’s a lot of work with little progress using an internal iframe node as a handle. Anyway, here are two solutions, the first one doesn’t work really well, but if you can get it to work, it may be more desirable.

    main.html (plagiarized from the demo)

    <div id="draggable" class="ui-widget-content" style="position:relative;">
        <p class="ui-widget-header">I can be dragged only by this handle</p>
        <iframe name="iframe1" src="inner-handle.html" height=50 width=80></iframe>
    </div>
    

    inner-handle.html

    <html>
        <head>
            <script type="text/javascript" src="../../jquery-1.4.2.js"></script>
        </head>
        <body>
            <div id="innerHandle">handle</div>
        </body>
    </html>
    

    JavaScript

    $(function () {
        var moveEvent;
        $(document).mousemove(function (e) {
            moveEvent = e;
        });
    
        $("#draggable").draggable();
        $('iframe', '#draggable').load(function () {
            $('iframe', '#draggable')[0].contentWindow.$('#innerHandle').mousedown(function (e) {
                $('#draggable').draggable().data('draggable')._mouseDown(moveEvent);
                return false;
            });
        });
    });
    

    It took me a while to find something that “worked.” The problem here was that since the mousedown event occurred on an element inside the iframe, the mouse event is relative to the iframe, not the main document. The workaround is to have a move event on the document and grab the mouse position from there. The problem, once again, is that if the mouse is inside of the iframe, it is “not” moving according to the parent document. This means that the drag event only happens when the mouse reaches the edge of the iframe into the parent document.

    A workaround for this might be to manually generate events with the calculated position of the iframe relative to its mouse movement. So when your mouse moves within the iframe, calculate its movement using the coordinate of the iframe to the parent document. This means that you need to use the event from the mousedown and not the mousemove,

    $('iframe', '#draggable')[0].contentWindow.$('#innerHandle').mousedown(function (e) {
        // do something with e
        $('#draggable').draggable().data('draggable')._mouseDown(e);
        return false;
    });
    

    The second solution is the way you have mentioned, have an absolute positioned div over the iframe itself. I have no trouble in getting the div to be on top of the iframe, that is,

    <div id="draggable" class="ui-widget-content" style="position:relative;">
        <p class="ui-widget-header">I can be dragged only by this handle</p>
        <iframe name="iframe1" src="inner-handle.html" height=50 width=80></iframe>
        <div style="position: absolute; height: 30px; width: 30px; background-color: black; z-index: 1000;"></div>
    </div>
    

    The problem with your div being behind the iframe might be because the z-index is off. If you declare your div before the iframe and you didn’t specify the z-index, then the iframe will be on top.

    Whichever way you choose, good luck!

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

Sidebar

Related Questions

Ok - a bit of a mouthful. So the problem I have is this
Yes, I know this question is kind of a mouthful of everything... I have
This one is a mouthful! Basically I'm trying to send all of my Rails
That's a mouthful of a question but basically I want to know if I
:) My question is quite a mouthful. This is a WinForms question : I'm
In this question, the asker requests a solution that would insert a space every
That title is a mouthful and a bit confusing, but you are still reading
For me, this is quite a mouthful of code. I understand the pieces of
This is a mouthful, so here's a piece of code as an example: template<typename
Okay, the title is a mouthful and I think that's probably why it has

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.