Forum Moderators: open

Message Too Old, No Replies

ondrag replacement

Trying to move to validated code

         

Robin_reala

4:01 pm on Jan 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi, my company is beginning to move towards validating all our websites before delivery which is working fine for most pages. I'm having a specific problem though with one of them, which uses an 'ondrag' event handler. Obviously this fails validation and has to go, but I'm not a Javascript expert and can't work out what to replace it with. Simply removing that event handler leaves the page functional (you can click, move the mouse, then click again) but not particularly user friendly. Anyone have any idea what could replace this?

Thanks,
-Robin

tforcram

9:10 pm on Jan 19, 2005 (gmt 0)

10+ Year Member



I didn't know that ondrag wasn't standard, but I just looked it up and sure enough it doesn't pass. The only thing I can think of would be to write your own ondrag function using onmousedown and onmousemove, both of which should validate fine.

Rambo Tribble

10:48 pm on Jan 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ondrag is an IE 5+/Win-only event.

Robin_reala

11:44 pm on Jan 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, I came to the same conclusion on onmousedown etc, but as I said - I'm not a javascript person. It's going to take me ages to work out how to do this, so I was looking for a 'quick fix'. Thanks anyway.

Bernard Marx

1:11 pm on Jan 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There have been a few threads on a related theme. My conclusion (based upon the opinions of others) on validation is this:

Browsers don't validate webpages against W3C DTDs. They probably never will. However, some of them are getting very strict about 'well-formedness'. I still haven't seen ANY argument that shows the benefits of validating code per se. However, it's certainly a good idea to use a validator to check that your pages' code is well-formed.

WRT the 'non-standard' event-handlers, you have a few choices:

1. Write your own DTD (hmmm!)
2. Remove the the offending instances for the purposes of validation, then stick them back in again.
3. Simply ignore any validator warnings that are just dull stuff about "ondrag".
4. Leave those event handlers out entirely, and add them via script when the page downloads.

Robin_reala

1:59 pm on Jan 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nah, it's cool, we're leaving it in. The way I figure it - it's not like I'm writing tag soup. In all likelyhood it'll be the only thing that fails validation on the entire site, and it's in there to provide specific extra functionality to a large percentage of users, not because we don't realise it's nonstandard.