Re: Event Handling via CSS



On Apr 21, 3:32 pm, Ricardo <ricardob...@xxxxxxxxx> wrote:
On Apr 21, 11:54 am, Roger <roger.gilre...@xxxxxxxxx> wrote:



On Apr 20, 3:25 pm, Thomas 'PointedEars' Lahn <PointedE...@xxxxxx>
wrote:

You appear to have acquired a number of misconceptions and false
terminology, which hinder understanding.

c.janardhanre...@xxxxxxxxx wrote:
I have seen sites using css attribute like "hover" to make dynamic
websites.

Those are pseudo-classes, not attributes:

<http://www.w3.org/TR/CSS21/selector.html#dynamic-pseudo-classes>

In some sites most elements don't have direct event handlers like
'mouseover', 'mouseout' etc  attached to html elements. Instead they
use CSS.  Could any one you give me some idea about invoking
JavaScript event handlers via css for CSS attributes like "hover"?

`mouseover', `mouseout' etc. are _not_ "event handlers", those are event
types.  There is also no such thing as "JavaScript event handlers".  And
even if there were, you could not "invoke" them "via css"; CSS is merely
a formatting language.

<http://www.w3.org/Style/CSS/>

When the user or a program does something in a user agent, an event
occurs.  That may create an event object to propagate the event in the
document tree.

<http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-flow>
<http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.htm...>

It may also, rather independently of the DOM, trigger a style *** selector
that uses a dynamic pseudo-class.

DOM implementations provide internal event-handlers so that code may
handle these events.  Event-handlers call one or more event-listeners; the
latter can be added with implementations that implement specified interfaces.

<http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventListener>
<http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.htm...>

HTML elements provide event-handler attributes which value is supposed to be
code written in a scripting language that is executed when the event occurs.

<http://www.w3.org/TR/html401/interact/scripts.html#h-18.2.3>

(Here event-handler attributes are called "events"; watch the date of this
Specification and don't let yourself be confused by this.)

DOM objects may provide proprietary event-handler properties which value is
supposed to be (a reference to) a callable object that contains the code to
be executed on event.  If such a DOM object represents an element in the
document, then that element does not need to have one of the aforementioned
event-handler attributes specified, provided there is an event-handler
property for that attribute.

There are also proprietary events and corresponding event-handler properties
that have no corresponding event-handler attribute in Valid markup, e..g.
<https://developer.mozilla.org/en/DOM/element#Event_Handlers>

(Noticed that there has been no mentioning of JavaScript until here?  For
these features are independent of a programming language.)

Now, DOM implementations also provide properties that implement interfaces
of CSS-related APIs:

<http://www.w3.org/TR/DOM-Level-2-Style/css.html>

You can use these properties to manipulate style sheets, e.g.

  element.style.display = "none";

to prevent an the element that is represented by the object `element' refers
to from being rendered.

However, you only need to do this for user agents that do not support the
corresponding CSS property, or pseudo-class for the element in question, or
CSS at all.

E.g: In hp.com, tabs like 'Support & Drivers' or 'Shop for Products'
are <a> HTML elements which don't have any event handlers directly
attached to them. Still they modify the DOM on mouseover/out.

If anything, they would modify the document tree; the DOM is a *model*, an
API instead, and usually not modified by an application using it.  (In fact,
it is strongly recommended against trying to modify a DOM implementation on
the fly; the objects provided are *host* *objects*, not, e.g. ECMAScript
native objects.)

I believe they are done via CSS.

The content is styled with CSS, but I presume the content is exchanged with
 the IXMLHTTPRequest API (XHR, also known as AJAX -- Asynchronous JavaScript
and XML).

<https://developer.mozilla.org/en/AJAX>

Of course, this doesn't work where XHR support is unavailable, and it can
cause considerable delays if XHR support is available but there is small
bandwidth or the display device is a mobile one.

In fact, the whole HP website is not exactly a showcase of good Web
authoring.  Starts with

<http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwww.hp.com%2...>
| 105 Errors, 15 warnings

<http://jigsaw.w3.org/css-validator/validator?profile=css3&warning=2&u...>
| Sorry! We found the following errors (6)

and ends with their usingjQueryfrom which you should stay farawayat
least at this point of its development.

Or ever as they will never learn.  I actually posted a message (under
a pseudonym of course) to their forum once:

http://groups.google.com/group/jquery-en/msg/473e3de5293e34f8

Banned immediately for stating that jQuery uses browser sniffing.
Probably fired their moderator too.  :)

More evidence that they are terminally stuck in the year 2000 and
there is no hope for their plug-in system:

http://groups.google.com/group/jquery-en/browse_thread/thread/896ad39...

Development group is nuts too:

http://groups.google.com/group/jquery-dev/browse_thread/thread/102a0e...

Sure, use jQuery with XHTML.  It blows up real good.

Damn, banned again.  Two messages, two groups, two bans.  Has to make
you wonder why they are so scared of criticism and why they would try
to shield their users from relevant issues.  Doesn't really bode well
for the future and past and present versions are obviously out of the
question.

Speaking of the future, I think most of the "supported browsers" have
QSA now.

This is Sizzle:

if ( document.querySelectorAll ) (function(){
        var oldSizzle = Sizzle, div = document.createElement("div");
        div.innerHTML = "<p class='TEST'></p>";

        // Safari can't handle uppercase or unicode characters when
        // in quirks mode.
        if ( div.querySelectorAll && div.querySelectorAll(".TEST").length ===
0 ) {
                return;
        }

        Sizzle = function(query, context, extra, seed){
                context = context || document;

                // Only use querySelectorAll on non-XML documents
                // (ID selectors don't work in non-HTML documents)
                if ( !seed && context.nodeType === 9 && !isXML(context) ) {
                        try {
                                return makeArray( context.querySelectorAll(query), extra );

Note.  No steak.

                        } catch(e){}
                }

                return oldSizzle(query, context, extra, seed);
        };

        Sizzle.find = oldSizzle.find;
        Sizzle.filter = oldSizzle.filter;
        Sizzle.selectors = oldSizzle.selectors;
        Sizzle.matches = oldSizzle.matches;

})();

I recognize *that* pattern.  Now if people can figure out that
"chaining" is just:

return this;

...nobody will feel compelled to rely on jQuery's Script of the Month
Club again.

You seem to enjoy being banned. You certainly use aliases for a "good"
reason...

LOL. A *very* good reason. Resig would never let me in that group.
Would have biased the results for sure. :)


In response to "please keep discussions on track and civil":
"Nice sentiment.  Do you own the place?  If so, you are a really lousy
moderator (especially since you don't follow the discussions
closely.)"

Who are you talking to?


"I dare you to ban me (would be your loss.)"

And wouldn't you know? He actually *did* (despite the public
outcry.) Supposed to outgrow taking dares by five.


About future enhancements plans for jQuery:
"Then everybody can upgrade your monolithic mess again?
Is this project a long-running practical joke are are you really
serious?"

For an expert, your understanding of frameworks seems flabby. XHTML

Did you mean "expert?" Flabby? As in fat?

served as application/xhtml+xml is not a reality in the web right now

Thanks for that nugget, "Ricardo." You guys do operate with blinders
on, don't you? Of all of the library authors on the planet (quite a
few these days), you picked the *one* who has actually published an
XHTML compatible library. So much for luck.

for lack of support. jQuery is aimed at development of real websites.

See, that is where you are wrong. For an "expert", your understanding
seems acutely anorexic. I remember you as the one who recommended
using an htmlFor attribute in markup to work around jQuery's idiotic
attr method. For God's sake.

If that's not your game just forget it.

Of course, the entire point was that Resig didn't realize what you
just tried to say. jQuery cannot run in an XHTML DOM. Of course, it
isn't too hot with HTML either. Or XML for that matter. It's pretty
much a train wreck in any language which is unsurprising given the
conductors.
.


Loading