[Javascript] Safari issues or better saying poor programming issues

MEM talofo at gmail.com
Fri Apr 2 04:34:08 CDT 2010


2010/3/31 David Lovering <dlovering at gazos.com>

> I would like to offer an uninformed guess as to why the onClick works in
> this context while the onFocus doesn't (at least consistently, across
> multiple browsers).
>
> The onFocus event occurs as soon as the cursor sweeps across a focusable
> object, and has nothing to do with when the value and/or internal state
> variables are changed.  The onClick on the other hand forces a 'select'
> state on the object, assuming it isn't already deactivated - as well as
> launching whatever scripts are tied to the event handler.  This is due in
> part to a subtle confusion between browsers as to what 'focus' and 'select'
> actually means - some don't lock focus until a select is enacted, while
> others are more general and adhere better to W3C DOM guidelines.
>
> When an onClick occurs it generally locks both focus and select, as well as
> creating the 'click' event itself.  [Assuming again the object hasn't
> already been disabled or rendered unfocusable].  Then it is merely a matter
> of sorting out the precedence of which comes first - onClick, onSelect, or
> onFocus.  If you want to force a uniform interpretation of 'focus' you can
> create your own equivalent by doing a real-time cursor coordinate readout
> and then pulling up the window object at that coordinate, but that is
> hugely
> expensive in terms of CPU event management and is not considered good
> programming practice.
>
> This pretty much works everywhere, across every browser.  It should be
> noted
> that some (like IE7 and beyond) use somewhat proprietary DOM notation which
> may not port everywhere - but since the Safari people also use some
> marginally proprietary constructs [probably to facilitate carry-over from
> the earlier Applescript event handlers], they are not entirely blameless
> either.  Firefox and others have their own issues, although Firefox at
> least
> allows you to get in and monkey with the config settings for better
> adherence to the model of choice you envision.  IE7+ can also be tweaked,
> but usually at some level requires resedit to make everything 'stick'.
>
> The best way to be absolutely portable in the Javascript domain is to write
> an onLoad preamble that senses the browser platform, and then customizes
> the
> event particulars appropriately with handlers that take these oddities into
> consideration.  Actually, I lie - the best way ever is to have every
> browser
> conform exactly and completely with the same standard down to the tiniest
> detail; but short of a Second Coming I think the chances of that happening
> are slim to none.  A good example of this dichotomy is the classic 'keyval'
> issue, which has historically been handled in quite different ways in
> nearly
> every browser.
>
> -- Dave Lovering
>

 Thanks a lot David for your comments and time into this.

I'm used to CSS differences among browsers, so I (believe) perfectly
understand what you mean.
I thought, however, that IE was the black sheep here, that all other
browsers, the so called "compliant browsers", where, I believed ,Safari
entered as well, where (the compliant browsers) dealing nice between them on
the most common properties at least.

None of the existing browsers are absolutely conform the w3c standards, I
knew that, however, I thought that an "event listener" (may we called like
this) like onFocus on a form element, should be at the state where all
browsers agree.

Until know, I just looked into my IDE and if I see the logo of 3 or 4 major
browsers, I thought I could apply that property. I see however, that it is
not always true so, what I would like to ask is, where do you js gurus, look
when you have to see which property can you use in cross browser way, and
which property should you avoid?

Of course, doing a js per browser is also a way but, honestly, I don't
believe that learning all proprietary properties (sorry for this redundancy)
of all browsers are on my capacities and, I would like to develop in the
same way I do with css, I will code compliant, if the browsers don't
understand the compliant code, I will deal with that extra on extra charge
as well.

But before I can take this way, I really would like to understand if there
is a minimum that we can do, on this compliant field. Can we?


Thanks a lot for your time and consideration once again, I will reforge then
my two main questions:
a) is there a place/something were we can see what should we use and what
should we avoid ?

b) is there a compliant trail that we can follow to produce, at least, the
minimum? (I believe when some js frameworks talk about cross-browser
support, I hope, they are walking on that path, or not?) However, and before
I dig into some fw, I would really like to understand DOM and proper js
first. So, and before I get lost again: Can I follow some compliant trail
or, there is no such thing to follow?




Regards,
Márcio


More information about the Javascript mailing list