Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Power Lifting Lever Belt
SkullVamp
Updated:
Saturday at 10:32 PM
Ad icon
port.lk Domain for sale
Lankan-Tech
Updated:
Saturday at 3:55 PM
Colombo
Kaduwela - Two Storey House for Sale
dilrasan
Updated:
Thursday at 2:23 PM
Ad icon
Wechat qr verification
Pawan2005
Updated:
Thursday at 1:28 AM
🚀 GOOGLE AI PRO 18 MONTHS ACTIVATION 🚀
sayuru bandara
Updated:
Wednesday at 5:34 PM
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
Javascript Drag & Drop.
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Core" data-source="post: 10769236" data-attributes="member: 263471"><p><strong>You can use this method on your blog to make any item drag-able.</strong></p><p><strong></strong></p><p><strong>can you see this bunch of code</strong></p><p><strong></strong></p><p><strong><div></strong></p><p><strong><img src=".jpg" alt="earth" title="earth" id='divStyle' /></strong></p><p><strong></div></strong></p><p><strong></strong></p><p><strong>so insert your elements which need to be dragged instead image.</strong></p><p><strong>and make its name divStyle.</strong></p><p><strong></strong></p><p><strong>Copy paste onto note pad and save it with .html extension.</strong></p><p><strong>that's all.</strong></p><p><strong></strong></p><p><strong></strong></p><p>Don't steal my codes without my permission. </p><p>[CODE]</p><p><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></p><p></p><p><html></p><p> <head></p><p> <style type='text/css'></p><p> #divStyle{</p><p> position:absolute;</p><p> //background-color:red;</p><p> //width:50px;</p><p> //border:solid 2px;</p><p> //border-color:black;</p><p> cursor:pointer;</p><p> }</p><p> </style> </p><p> </p><p> <script type='text/javascript'></p><p></p><p> document.onmousedown = mouseDown;</p><p> document.onmouseup = mouseUp;</p><p> </p><p> function mouseDown(event)</p><p> {</p><p> //check the browser</p><p> if(window.event)//for IE browser</p><p> {</p><p> //get the event trigged object</p><p> ObjEvent = event.srcElement;</p><p> }else if(event.which)</p><p> {</p><p> //for FF/Safari/Opera/ browser</p><p> ObjEvent = event.target;</p><p> }</p><p></p><p></p><p> //check it got the appropriate object</p><p> if(ObjEvent.id = "divStyle" )</p><p> {</p><p> //then get the left top positions of the object</p><p> objLeft = parseInt(ObjEvent.style.left);</p><p> objTop = parseInt(ObjEvent.style.top);</p><p> //get the mouse pointer's positions on the screen but on the object</p><p> cltX = event.clientX;</p><p> cltY = event.clientY;</p><p> //then call for the move event when it's needed</p><p> document.onmousemove = mouseMove;</p><p> }</p><p> return false;</p><p></p><p> }</p><p></p><p> function mouseMove(event)</p><p> {</p><p> //get the current location of the moving</p><p> currentX = event.clientX;</p><p> currentY = event.clientY;</p><p> </p><p> //set the new location of the object which will be redraw in each time when items is being moved</p><p> ObjEvent.style.left = objLeft+(currentX - cltX )+ "px";</p><p> ObjEvent.style.top = objTop+(currentY - cltY)+ "px";</p><p> return false;</p><p> }</p><p></p><p> function mouseUp(event)</p><p> {</p><p> document.onmousemove = null;//cancel the moving</p><p> return false;</p><p> }</p><p></p><p></p><p> document.onmousedown = mouseDown;</p><p> document.onmouseup = mouseUp;</p><p></p><p></p><p> </script></p><p> </head></p><p><body></p><p></p><p> <div></p><p> <img src=".jpg" alt="earth" title="earth" id='divStyle' /></p><p> </div></p><p></p><p> <script type='text/javascript'></p><p> //set the initial location</p><p> ObjEvent = document.getElementById("divStyle");</p><p> ObjEvent.style.left = "100px";</p><p> ObjEvent.style.top = "150px";</p><p> </script></p><p></p><p></body></p><p></p><p></html>[/CODE]<strong><span style="font-size: 12px">By CORE/ 2010/05/20 Originally was written</span></strong></p><p><strong><span style="font-size: 12px">Made on Elakiri.com on 2011/08/01</span></strong></p></blockquote><p></p>
[QUOTE="Core, post: 10769236, member: 263471"] [B]You can use this method on your blog to make any item drag-able. can you see this bunch of code <div> <img src=".jpg" alt="earth" title="earth" id='divStyle' /> </div> so insert your elements which need to be dragged instead image. and make its name divStyle. Copy paste onto note pad and save it with .html extension. that's all. [/B] Don't steal my codes without my permission. [CODE] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <style type='text/css'> #divStyle{ position:absolute; //background-color:red; //width:50px; //border:solid 2px; //border-color:black; cursor:pointer; } </style> <script type='text/javascript'> document.onmousedown = mouseDown; document.onmouseup = mouseUp; function mouseDown(event) { //check the browser if(window.event)//for IE browser { //get the event trigged object ObjEvent = event.srcElement; }else if(event.which) { //for FF/Safari/Opera/ browser ObjEvent = event.target; } //check it got the appropriate object if(ObjEvent.id = "divStyle" ) { //then get the left top positions of the object objLeft = parseInt(ObjEvent.style.left); objTop = parseInt(ObjEvent.style.top); //get the mouse pointer's positions on the screen but on the object cltX = event.clientX; cltY = event.clientY; //then call for the move event when it's needed document.onmousemove = mouseMove; } return false; } function mouseMove(event) { //get the current location of the moving currentX = event.clientX; currentY = event.clientY; //set the new location of the object which will be redraw in each time when items is being moved ObjEvent.style.left = objLeft+(currentX - cltX )+ "px"; ObjEvent.style.top = objTop+(currentY - cltY)+ "px"; return false; } function mouseUp(event) { document.onmousemove = null;//cancel the moving return false; } document.onmousedown = mouseDown; document.onmouseup = mouseUp; </script> </head> <body> <div> <img src=".jpg" alt="earth" title="earth" id='divStyle' /> </div> <script type='text/javascript'> //set the initial location ObjEvent = document.getElementById("divStyle"); ObjEvent.style.left = "100px"; ObjEvent.style.top = "150px"; </script> </body> </html>[/CODE][B][SIZE=3]By CORE/ 2010/05/20 Originally was written Made on Elakiri.com on 2011/08/01[/SIZE][/B] [/QUOTE]
Insert quotes…
Verification
Dawasata paya keeyak thibeda?
Post reply
Top
Bottom