Draggable Divs

C

Carl Gilbert

Hi

I am trying to allow a user of a web site to move an image around the page
using draggable Divs. I have tried using some script from
http://www.mattkruse.com/.

In particular: http://www.mattkruse.com/javascript/dragiframe/ which caters
for draggable IFrames. I think I can use the same code for Divs but I have
no success as yet.

I have to following code but I can not work out what I am doing wrong.

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="ImageUpload.WebForm1"%>
<SCRIPT language=javascript src=dragiframe.js></SCRIPT>
<STYLE>.drag{position:absolute; cursor:hand;}</STYLE>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>WebForm1</TITLE>
</HEAD>
<!--<BODY onLoad="addHandle(document.getElementById('div1'), window);">-->
<BODY onLoad="addHandle(document.getElementsByTagName(Div).item(0),
window);">
<DIV id="div1" name="div1" class="drag"
style="width:30;height:30;top:200;left:200">
<IMG src=cross.gif>
</DIV>
</BODY>
</HTML>

Can anybody identify where I am going wrong or if I am missing anything?

Regards, Carl

Note: I have also downloaded dragiframe.js and placed it in the same folder
as the web page.
 
M

Matthew Lock

Without knowing what's in dragiframe.js it's hard to know what the
problem is. Try adding position: absolute in your div to allow it to
actually be positioned anywhere.
 
R

RobG

Carl said:
Hi

I am trying to allow a user of a web site to move an image around the page
using draggable Divs. I have tried using some script from
http://www.mattkruse.com/.
[...]

The script specifically looks for an IFRAME (see line 175).
You need to make it look for a div and manage the other parts of
the code that require an IFRAME not a div.

Maybe Matt is lurking?

Why not just use an IFRAME and be done with it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top