Jump to content
xisto Community
Sign in to follow this  
minimcmonkey

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

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.