Dragging when mouse on  Iframe Content

Posted on 2008-06-23
Last Modified: 2012-06-21
Hi, I have a draggable DIV that has Iframe in its content section. The draggable popup is defined as

<div id=popupcontainer>
  <div id='popupInner'>
    <div id='popupTitleBar class=dragHandle> title </div>
    <div id='content'> <iframe src="'+ gDefaultPage +'" style="width:100%;height:100%;background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" ></iframe>

The drag routine is defined  on the popupContianer div. The dragHandle Div is the handle clicking on which I will be dragging the entire div. the problem is when I move the mouse over the content of the frame, the popup is not moving. Once I am out of the iframe content the popup is dragged to the new position.

How do I keep the iframe moving even whenever the mouse is over the iframe content?
Question by:zmoidin
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
  • 4

Author Comment

ID: 21850688
here is a sample drag-resize code. You could see in this that the iframe doesnot smoothly drag or resize according to the event. Could someone point out where I am going wrong.

While dragging the popup, if the mouse moves into the iframe content the popup doesnt moves. Also there seems to be problems wiht setting the height of the div in accordance with iframes.

could some one point me in the right direction.

Author Comment

ID: 21859648
This is also called the sticky iframe issue.
LVL 54

Expert Comment

ID: 21871822
You could try creating a layer over the iframe.  That way the page will still have an element and focus in that area, even over the iframe.  Of course this may cause a problem if you need to work in the iframe.  If that will be the case then you might try hiding the layer until the drag starts and then have the event show it.

I haven't tried this method to see if it would work though or how well it will work.  Let me know if you have a question and I can try to provide details if you need them.


Author Comment

ID: 21878768

your solution to create a layer seems the right way to go. Is it possible for you to provide more details on implementing this layer. I tried creating a div

<div id=popupcontainer>
  <div id='popupInner'>
    <div id='popupTitleBar class=dragHandle> title </div>
<div id='frameLayer'> </div>
    <div id='content'> <iframe src="'+ gDefaultPage +'" style="width:100%;height:100%;background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" ></iframe>

This didnot solve the problem. I also notice that after I select the popup for dragging. When I move the mouse outside the popup the events work fine, when I move the mouse inside the iframe none of the events are recognized.

any idea why that happens ? This happens both in IE and Firefox.

thanks in advance

Accepted Solution

zmoidin earned 0 total points
ID: 21878859
I found that the problem exists because the iframe contents are treated as a separate document than the original page. Hence the iframe events are not propogated to the main document.

Theoretically what needs to be done is on loadign the iframe, I need to assign the dragResize event handlers to the iframe mouse events. I think that will fix the problem. But I have no idea how to make synchronize the iframe events with the main document events. Can someone help?

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
Date on a table 16 37
Hide and Unhide Table 6 27
How do I Enable submit button only if listbox has items 4 36
powershell automatic variable for results 21 28
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

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