Fred Oz wrote:
Fred Oz wrote:
[...]
Ooops, left out xmouse. Only need to feature detect once (it's
very likely that if clientY is supported, so is clientX...):
function Mouse(evnt){
var e = evnt || window.event;
if (e.clientY)
ymouse = e.clientY+ClockFromMouseY;
xmouse = e.clientX++ClockFromMouseX;
<snip>
It probably is valid to assume that an event object supporting clientX
will also support clientY. However, The style of testing you have
applied is problematic because the values being referred to are
primitive and so a type-converting test will produce results that depend
on the actual value. While an unsupported property will be undefined and
so type-convert to boolean false a numeric zero value (or an empty
string) will also type-convert to false. Where a property to be
tested/verified is an object or function, that will be undefined when
not implemented (and possibly null where supported but not present in
context), type-converting tests are probably optimum. Where a property
is expected to have a primitive value when implement a - typeof - test
is often necessary to produce reliable results.
Unfortunately, - typeof - testing is less efficient, but it can be
arranged that the testing does not need to be repeated each time a value
is read; the initial assumption still applies, if an event object
implements clientX the first time it is tested then the chances are good
that all (mouse related) event will also implement clientX, etc.
Richard.