Richard Cornford wrote:
Peter Michaux wrote:
then hopefully we can assume that if event.clientX exists
Why assume that?
and is a number
that clientX is in window coordinates.
You just made the wrong assumption for Opera <= 6.
Do you know of any browsers other than Opera <=6 where clientX is not
in window (ie client-area) coordinates?
Can you find a formal standard that says what values the clinetX/Y
properties of an event object are supposed to report? Without that there
is no meaning to "properly".
At least I am in good company with this error. :)
http://groups.google.com/group/comp....44f181aac86c37
I can imagine that we need to test that not only every
feature we want to use exists but that it works properly
also. Yikes!
Not every feature, but certainly the ones that are known to be
problematic.
I agree with this pragmatic approach but this approach results in
somewhat brittle scripts that may break in a future browser. If the
developer knows all problematic features in all existing browsers then
the resulting scripts would not be very brittle but still brittle to
some degree. So with this approach, which is probably the only
practical one with even moderately complex scripts, there is no way to
proclaim a script is cross-browser. The best possible claim would be
multi-browser where multi means all browsers in existence and known to
the developer.
If you going to normalize client co-ordinates into page co-ordinates
then you are not dealing with just one number.
Remember that, for example, when the corresponding scroll value is zero
the difference between client-area and page co-ordinates is zero. So
some of the time you don't need to know the difference, and as soon as
you do need to know you have more information to make the judgement on
(i.e. if the clientX/Y is smaller than the scrollLeft/Top then they must
be client-area co-ordinates not page co-ordinates).
This example doesn't seem to be enough information in all cases. If the
browser window is scrolled only one pixel then this approach wouldn't
work. I imagine you have other plans if needed.
I can see setting up a very elaborate grid of invisible divs 1px wide
or tall with known positions and comparing the mouseover event
coordinates with the known position of the div in question.
When the window is scrolled, I could try to place a little invisible
div under the mouse based on the clientX information alone. If the next
mousemove is over the little div then clientX is in page coordinates.
This seems ridiculous and probably is especially in light of your
earlier pragmatic advice: since Opera <=6 cannot use my script and if
all other browsers without pageX and with clientX give clientX in
client-area coordinates then I don't need to worry or go to such great
lengths.
You can arrange to never learn of other browsers with similar issues by
the simple expedient of never looking (that is quite a popular strategy
;)
It is an endless stream of browser installations on my computer. It is
all interesting but it definitely is a very time consuming task to
learn to write quality browser scripts. And learning is likely an
unending process.
I can understand the appeal of the Yahoo! A-grade browser list to
alleviate testing tedium and compatibility/bug issues.
http://developer.yahoo.com/yui/artic...ser-chart.html
The biggest problem with this list is the Yahoo! UI library's use of
the list. They really don't follow this graded browser strategy at all
except for the A-grade browsers. If I have a C-grade browser then parts
of the Yahoo! UI library will be defined even though they won't work. A
script based on Yahoo! UI could work up to a certain stage and then
break meaning the page is useless.
The list is also very limited and it is not apparent what they expect
to happen if another browser is used. The only conclusion I can make is
they don't care. Which means, for example, they don't care about Safari
1.3 which I think is strange. I know someone still using Mac IE 5.
Peter