How to make div tag resizable using javascript? get the position of mouse click

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pooja Deshpande

    #1

    How to make div tag resizable using javascript? get the position of mouse click

    Code:
    function _move(e)
          {
            mouse_x = document.all ? window.event.clientX : e.pageX;
            mouse_y = document.all ? window.event.clientY : e.pageY;
            if(_item != null)
            { 
              _item.style.left = (mouse_x - ele_x) + "px";
              _item.style.top = (mouse_y - ele_y) + "px";
              
                if(_item.offsetLeft < 0) 
                {
                     _item.style.width  =  _item.style.pixelWidth - (mouse_x - ele_x) + "px" ;
                }
                if(_item.offsetTop < 0)
                {
                  _item.style.height =  _item.style.pixelHeight -(mouse_y - ele_y)+ "px"  ;
                }
                
                if(_item.offsetLeft > 0) 
                {
                     _item.style.width  =  _item.style.pixelWidth + (mouse_x - ele_x) + "px" ;
                }
                
                if(_item.offsetTop > 0)
                {
                    _item.style.height =  _item.style.pixelHeight +(mouse_y - ele_y)+ "px"  ;
                }
            }
          }
    Last edited by Dormilich; Nov 10 '10, 09:03 AM. Reason: please use [CODE] [/CODE] tags when posting code
Working...