Implementation of Behaviors in Internet Explorer

Implementation below is a generalization of Ben Nolan’ idea of behaviors. Behaviors were implemented natively in Sciter and HTMLayout and here is their emulation for the Internet Explorer.

Basic principle is simple, CSS declaration like this:

li.myclass 
    { 
      prototype: MyBehavior; /* see var MyBehavior below */
    }

binds class of DOM elements with the “prototype behavior object” – collection of event handlers defined in script nearby:

var MyBehavior = 
    {
      attached:    function() { ... },
      onclick:     function() { ... },
    }

Thus after loading HTML that contains something like this:

<ul>
  <li class="myclass">Element with MyBehavior</li>
  <li>Element without behavior</li>
</ul>

first element will behave as MyBehavior.

Here is an implementation of the Behaviors Framework – HTML document that demonstrates basic principle. Implementation is based on the fact that Internet Explorer allows you to define custom attributes in CSS declarations. I will appreciate if someone will tell me how to define something like this but for other UAs (browsers).

This may be interesting too:
“Designing Reusable UI Components in Sciter: Part I, Part II and Part III“.


Here is Dave Herman’ version of original behavior.js of Ben Nolan.

Here is another sample for IE: Simple collapsible tree.

HTML5, broken hopes.

I am tracking HTML and CSS design efforts on W3C last three years.

My main area of interests is in CSS development as I think that in HTML/CSS/Script triade CSS as a technology is the weakest area. Next is the Script. And HTML appears as the most stable thing among these three.

Since CSS1 we did not get anything changed in styling in principle. In particular CSS, as a technology, still failed to provide layout mechanisms needed by modern web applications. < table > markup is unbeatable yet – there are simply no equivalents for rowspan/colspan and flex length units used in tables ( remember that width=”60″ may serve role of pixels *or weight* in table layout). So advices like “tables are only for tabular data” are at least non-professional in current circumstances.

It appeared initially that WHATWG would focus on “needs of real-world authors” but for some reasons group started from fixing HTML. That is what I really do not understand. What conceptually is so wrong with HTML 4.01 that we need to fix it now forgetting about two other components? (The only thing to add is < video > element that I think really makes sense in shed of lights of the Tube and others.)

I believe that main problem of semantically bad markup on the Web now is not in HTML per se but, again, in CSS (and in scripting at the less extent). Lack of layout facilities in CSS forces us (real-world web designers and developers) to use markup for layout purposes more than it is really needed. Web authors, people who write content of the web are happy with the current HTML but professional web designers *are* the people who are “breaking the semantic web” now. Simply because CSS as a standard failed to provide layout features needed for modern web applications. I thought that was clear for everyone who is doing practical web design…

To be short I disappointed by direction where W3C decided to move development focus these days. And yet, here are HTML5 and HTML4 differences. Could anyone tell me what all this will change in principle except of breaking of what works already?

So far all corner stone Web technologies were production of concrete personalities and companies – not committees. As an example: HTTPXMLRequest ( one of features AJAX is based on) was born as a result of guerrilla’s action taken by team doing web access for Microsoft Exchange. And now the whole yahoo and google set of technologies is built on it. So is the question that worries me somehow: how Web technologies should be designed/evolve? What is the best procedure:
design-by-precedent, design-by-committee, design-by-public-bazaar or just wild competition among browser vendors? But this is, I guess, an idea of separate topic.