Draggable Divs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carl Gilbert

    #1

    Draggable Divs

    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="Web Form1.aspx.vb"
    Inherits="Image Upload.WebForm1 "%>
    <SCRIPT language=javasc ript src=dragiframe. js></SCRIPT>
    <STYLE>.drag{po sition:absolute ; cursor:hand;}</STYLE>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>WebForm1 </TITLE>
    </HEAD>
    <!--<BODY onLoad="addHand le(document.get ElementById('di v1'), window);">-->
    <BODY onLoad="addHand le(document.get ElementsByTagNa me(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.


  • Matthew Lock

    #2
    Re: Draggable Divs

    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.

    Comment

    • RobG

      #3
      Re: Draggable Divs

      Carl Gilbert wrote:[color=blue]
      > 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/.[/color]
      [...]

      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

      Comment

      • Matthew Lock

        #4
        Re: Draggable Divs



        could also try posting on Matt's forum. Maybe someone has already done
        it:

        Comment

        • RobB

          #5
          Re: Draggable Divs

          Carl Gilbert wrote:[color=blue]
          > Hi
          >
          > I am trying to allow a user of a web site to move an image around the[/color]
          page[color=blue]
          > using draggable Divs.[/color]

          (snip)

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



          Comment

          • Carl Gilbert

            #6
            Re: Draggable Divs

            > This is hard to beat (check out the "Optional Commands" in
            particular).
            [color=blue]
            > http://www.walterzorn.com/dragdrop/dragdrop_e.htm[/color]


            This is a great site. Thanks for the tip.

            Carl

            *** Sent via Developersdex http://www.developersdex.com ***
            Don't just participate in USENET...get rewarded for it!

            Comment

            Working...