Draggable Divs

Discussion in 'Javascript' started by Carl Gilbert, Mar 9, 2005.

  1. Carl Gilbert

    Carl Gilbert Guest

    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.
    Carl Gilbert, Mar 9, 2005
    #1
    1. Advertising

  2. Carl Gilbert

    Matthew Lock Guest

    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.
    Matthew Lock, Mar 9, 2005
    #2
    1. Advertising

  3. Carl Gilbert

    RobG Guest

    Carl Gilbert wrote:
    > 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?


    --
    Rob
    RobG, Mar 9, 2005
    #3
  4. Carl Gilbert

    Matthew Lock Guest

    Matthew Lock, Mar 9, 2005
    #4
  5. Carl Gilbert

    RobB Guest

    Carl Gilbert wrote:
    > Hi
    >
    > I am trying to allow a user of a web site to move an image around the

    page
    > using draggable Divs.


    (snip)

    This is hard to beat (check out the "Optional Commands" in particular).

    http://www.walterzorn.com/dragdrop/dragdrop_e.htm
    RobB, Mar 9, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. PilotYid
    Replies:
    4
    Views:
    398
    Andrey Kuznetsov
    Dec 28, 2005
  2. PilotYid
    Replies:
    0
    Views:
    378
    PilotYid
    Dec 27, 2005
  3. Shailesh Humbad

    resizable & draggable layers

    Shailesh Humbad, Aug 3, 2004, in forum: HTML
    Replies:
    1
    Views:
    529
    Vladdy
    Aug 3, 2004
  4. rich
    Replies:
    0
    Views:
    708
  5. maya
    Replies:
    4
    Views:
    224
Loading...

Share This Page