Solved

Dragging when mouse on  Iframe Content

Posted on 2008-06-23
5
535 Views
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>
     </div>
  </div>
</div>

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?
0
Comment
Question by:zmoidin
  • 4
5 Comments
 

Author Comment

by:zmoidin
Comment Utility
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.
dragresize2.zip
0
 

Author Comment

by:zmoidin
Comment Utility
This is also called the sticky iframe issue.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
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.

bol
0
 

Author Comment

by:zmoidin
Comment Utility
b0lsc0tt,

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>
     </div>
  </div>
</div>

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
0
 

Accepted Solution

by:
zmoidin earned 0 total points
Comment Utility
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?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now