I want two separate objects on a page to be moveable by the user - mouse click and drag. I’m having all sorts of problems achieving this. the following test code baffles me. Both objects get moved and I cannot work out why.
Any ideas will be gratefully received I don’t know what other detail to add. Both areas are the same but belong to different classes and have different IDs. the IDs of the second area do not appear in the javascript
As @rpg_digital said above your code is very old and unlikely to work cross browser as you have a very old doctype and are utilising quirks mode. That means that certain things will only work if the browser steps in and helps you along with them.
The percentage height on your divs won’t work in standards mode in the way that you have defined them and the js won’t update because you have not used units on your measurements (px).
You don’t really want to leave anything to chance so choose a current doctype (html5) and make sure you use units in your dimensions for css measurements.
i.e. turn the number into a string with units by appending + “px”.
For percentage height to work in standards mode you need an unbroken chain of heights all the way back to root so in your code you would need this:
html,body{height:100%;margin:0;padding:0;}
You also have typos in your css for the left:15% and left:75% (although they don’t make much sense as the 75% will move most of that element off screen to the right).
Even though you may be just learning there is no reason to learn the wrong way to do something as that just makes it harder to unlearn Try following the link that @rpg_digital pointed to
Bullshit Paul
Works fine now Gandalf spotted the spelling mistakes so I didn’t close my divs
px is really not required - never has been and I’ve been writing html since before it was invented! Yes, it’s in fact IBM-s dsoss we used to use for documentation - html has one extra tag
Thanks but what you wrote is furthermore irrelevant to the problem!
No typos by the way - they may not make sense to you but they do to me - and not part of the problem - what are you a nit-picker?
as I’ve probably been doing this since before you were born I doubt I need your tutorial. And you didn’t address the problem - Gandalf spotted the error - you didn’t - too high on your horse perhaps?
Members are giving their up their free time to help, and are offering that help based on their understanding of the issue. If they don’t have the full picture, that is not their fault, nor is it a reason to respond with insults.
By all means disagree, but please do it courteously.
Sorry if my comments upset you but just trying to point you in the correct way of doing things these days. You may indeed have a unique set up that allows you to use old fashioned code but of course we were not aware of that situation.
It would indeed be remiss of us not to mention code that is broken or malformed as the Internet is forever and anyone else looking at this thread may copy your code and try to use it and fail miserably as it certainly will not work in a standards doctype. Now that you have explained you have a special situation and are able to use old fashioned code then visitors here can be aware that the code is a special use case only.