Drag and drop the image!

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

    #1

    Drag and drop the image!

    Hi,
    I made a program to drag and drop the image using mouseevent, it only works
    on IE well, not on Netscape. Does anyone has the example suitable for
    Netscape? Please help. Thank you very much.

    yihan


  • Fabian

    #2
    Re: Drag and drop the image!

    yihan hu kiteb:
    [color=blue]
    > Hi,
    > I made a program to drag and drop the image using mouseevent, it only
    > works on IE well, not on Netscape. Does anyone has the example
    > suitable for Netscape? Please help. Thank you very much.[/color]

    Can you show us the code? It might only require minor tweaking to fit.
    And its something I want to do for one of my own projects too. You
    wouldn't want to save me loads of time would you :)


    --
    --
    Fabian
    Visit my website often and for long periods!
    Bersiaplah menghadapi terjangan badai kemenangan di AGAM69! Slot gacor RTP tinggi, deposit 10k QRIS 1 detik, bet 200 perak.


    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: Drag and drop the image!

      "Fabian" <lajzar@hotmail .com> writes:
      [color=blue]
      > yihan hu kiteb:[color=green]
      >> I made a program to drag and drop the image using mouseevent,[/color][/color]
      [color=blue]
      > Can you show us the code? It might only require minor tweaking to fit.
      > And its something I want to do for one of my own projects too. You
      > wouldn't want to save me loads of time would you :)[/color]

      Very simple example (dragging, no effect on dropping):
      ---
      <script type="text/javascript">
      function dragImg(img,evt ,how) {
      how = how || "relative";
      img.style.posit ion = how;
      var root = document.docume ntElement || document.body;
      var x = img.xPos || (how == "relative" ? 0 : img.offsetLeft) ;
      var y = img.yPos || (how == "relative" ? 0 : img.offsetTop);
      var mx = evt.pageX || evt.clientX + root.scrollLeft ;
      var my = evt.pageY || evt.clientY + root.scrollTop;
      document.onmous emove = function (evt){
      evt = evt || window.event;
      var newmx = evt.pageX || evt.clientX + root.scrollLeft ;
      var newmy = evt.pageY || evt.clientY + root.scrollTop;
      x += newmx - mx;
      y += newmy - my;
      mx = newmx;
      my = newmy;
      img.style.left = x+"px";
      img.style.top = y+"px";
      img.style.outli ne="2px solid gray";
      img.style.zInde x = "1";
      return false;
      }
      document.onmous eup = function () {
      document.onmous emove = document.onmous eup = null;
      img.xPos = x;
      img.yPos = y;
      img.style.outli ne = img.style.zInde x = "";
      return false;
      }
      return false;
      }
      </script>
      ---
      with
      ---
      <img src="..." onmousedown="re turn dragImg(this,ev ent)">
      ---
      or
      ---
      <img src="..." style="position :absolute;"
      onmousedown="re turn dragImg(this,ev ent,'absolute') ">
      ---

      Good luck.
      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      Working...