Call in: 5-5000, 3193
<a id="link" href="foo.html" onclick="doHighlight(0); return false;"
onmouseover="showHideLayer(this,1);" onmouseout="showHideLayer(this,0);"
onblur="killHighlight(0);">hello world!</a>
Over...and over...and over through the document.
<a id="link" href="foo.html">hello world!</a>
A best practice technique as well as an overall coding philosophy.
This all combines to give us easier to maintain documents that gracefully degrade.
<div id="foo">
<a href="#" onclick="doStuff(this);">bar</a>
<a href="#" onclick="doStuff(this);">baz</a>
</div>
This includes the body element's onload attribute!
<li id="li0"...
<li id="li1"...
aObj = document.getElementById("foo").getElementsByTagName("a");
for(i=0;i<aObj.length;i++)aObj[i].onclick = function() { doStuff(this);}
var liObj = document.getElementsByTagName("ul")[0].getElementsByTagName("li");
Behavioral elements added with Javascript, so no odd elements hanging about in the document when the functionality isn't available.
Example:
// we can't dynamically populate the photo caption without javascript, so
// we'll create it here instead of hard-coding it in the document
captionObj = d.getElementById("mContainer").appendChild(d.createElement("div"));
Instead of:
<div id="caption">This is where the caption will be.<div>
This works because the checkboxes are already in the document. When we determine that the user agent is capable of what we want to accomplish, we hide them.
Transitions are nice...but its the data that's important and ultimately what the user is there for.
This presentation software is an example of Unobtrusive Javascript. It is a collaborative work headed up by Eric Meyer called S5.
Go ahead and disable javascript and see what happens.
Thanks for coming! Any questions?