Honesty Rocks! truth rules.

Need Help With Javascript Drag And Drop Script Having trouble with javascript drag and drop script.

HOME      >>       Programming

minimcmonkey

hi, i have been trying to create a drag and drop menu for my new website, so that the navigation menu can be moved around the site. This is the code i have:

<html><head><title>Test run - Right click menu</title><script type="text/javascript">function coordinates(event){if (event.button==2) {var x=event.x;var y=event.y; }document.getElementById("element").style.left=x;document.getElementById("element").style.top=y;document.getElementById("element").style.visibility="visible";var oldx=x;var oldy=y;window.onmouseup=end();window.onmousemove=coordinates(event);}function end(){}</script> <style type="text/CSS">#element { position: absolute; top: 0px; left: 0px; background-color: 568934; border: 3px dashed; visibility: hidden; z-index: 1;}</style></head><body bgcolor="112233" onmousedown="coordinates(event)" oncontextmenu="return false;"><div id="element">hi<br><table><tr><th onmousedown="coordinatesb(event)">hi</th></tr></table>hi<br>hi<br>hi<br>hi<br>hi<br>hi<br></div> </body></html>

When i run this (in Internet Explorer) it says
"out of memory at line 8"
and there are errors at lines 14 an 51,
when i remove line 14, the error is seen on line 15 instead (because they do virtually the same thing)
At the moment, i havent made it work in firefox or any other browsers, and dont intend to until it works with IE. I am aware that it doesnt account for scrolling, but im adding all that stuff later.
Can anyone help?

I have tried using a javascript debugger, and syntax chgecker, ect, but i still can fix it...
any ideas?

Nabb

On line uh... 52... you wrote coordinatesb instead of coordinates.Not quite sure and I don't feel like debugging at the moment, but try using variable names that aren't x and y, that might be causing a problem.


minimcmonkey

I will try that, although i did build this using part of the code i used when i made a right click menu script, and the X and Y named variables worked fine then.thanks, ill give that a go.I did try using a variable debugger, but i didnt get any errors.


iGuest

Thanks a lot John Mike (or to whoever made this no-drag-and-drop script possible)!!You have truly made my day, because I've been looking for a good way to protect my images on the internet, and by far this is the best method I've come across!! Once again, thanks a lot!! :DD