View Full Version : Open iframe from link, then make it draggable

12-11-2005, 01:29 AM
Alright, having an issue here. I'm not huge on this stuff, but its relatively self explanatory (plus i just cut and paste) but im working on basically having a link that will open up an iframe window on the page. After that the iframe should be draggable by a table based on the ID of the table (source is available at http://www.mattkruse.com/javascript/dragiframe/). The problem that I'm having is that the iframe opens up fine, all the information is correct, and the draggable mouse icon appears when it goes over the table, but it doesn't drag at all. I can't seem to figure it out no matter how much I tinker with it. The function to add the iframe is as follows.

function addIframe () {
if (document.all)
'<iframe id="datamain1" name="datamain1" src="iframe3.html" width=180 height=730 scrolling=no allowtransparency="true" background-color="transparent" ><\/IFRAME>');

Any help would be greatly appreciated! thanks in advance!

12-11-2005, 04:33 AM
Where did you put the code to make the iframe dragable? On the parent page or on the page inside the iframe? Your example page is unavailable (404) at the moment. Have you tried:

DHTML Window (http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow.htm)

That is essentially a dragable iframe, all the rest is just added images and links that you can get rid of if you don't want them.

12-11-2005, 06:06 AM
Sorry, added in a ) in the link. There is simply a line you put in the body code of the iframe document. The page is http://www.mattkruse.com/javascript/dragiframe/ . That should work, like i said i just had the ) at the end (oops). Then also you simply load the dragifram.js with the <script> commands in the body document. It works fine with pages when the iframe isn't generated through the addiframe function, but after I load the iframe, its not draggable. Again, the cursor shows like it should be draggable, but doesn't let me drag. Weird, and I don't know why it wouldn't work since i'm just adding in the code through the function to the end of the document when you click the link. Everything else works... :confused:

12-11-2005, 08:12 AM
I couldn't find any iframes on that page that weren't dragable to some extent. Some problems do appear to be occurring though. One is that sometimes the iframe slips away and can become difficult or impossible to acquire again. Other times, if the iframe is acquired, it is difficult to let go. Iframes may be dragged outside the actual confines of the page (causing the page to grow in one or more dimension(s). It also seems as though there is sometimes bleed through from one iframe to the other when one is dragged it seems to move another or others as well. Some of these problems may just be artifacts of others or one other. The main problem is, as I see it, that any given iframe may be dragged beyond the original dimensions of the page that it is showing through onto. Since those dimensions and boundaries could be acquired from the code on the iframe pages, they should be established and limits set using them as to how far the iframe may be dragged off of the page. I vote for no portion of a dragable iframe being allowed to cross the edges of the parent page. I'd also vote for not dynamically adding a dragable iframe element to a page if, by doing that, you cause the page's original dimensions to change.

12-11-2005, 04:30 PM
Alright, theres certain ways to fix the problems you present... but thats not really the point. And theres a way to make it so you can't drag it off the page :

// Set to true to allow IFRAME objects to be dragged off the screen. This may
// make the handle be no longer reachable by the mouse, causing the IFRAME to
// be stranded.
// Defaults to false

Well you vote for not doing it the way I want it done :P hehe, doesn't seem too promising then. So then there isn't a way to do it, or it will simply be quirky (i like quirky!).