| home / programming / javascript / domloader | [next] |
|
By Kenneth Tibbetts (postmaster@yankeeweb.com)
It can be tough to be practical and ethical at the same time. Ethically, I believe in the W3C recommendations. I believe in advancing and supporting accessibility and the document object model (DOM). The Internet should exclude the fewest possible people. But practically speaking, I write code. And the code that I write usually requires a modern, document object supportive browser to really do its stuff.
My pages begin life as ordinary HTML and CSS. When I add scripts to these clean, valid pages, I wind up with something everyone can use, to some extent. If I am very, very careful.
It is not too difficult to write pages that work in either and both of these cases:
It is fairly easy to write scripts that work in the newest browsers. The trouble starts when the real world gets online, with browsers that support some but not all of the script. Give a half-smart browser enough code and it'll hang itself.
I run a small shop, with a small budget. I don't have a test machine for every platform. I want to deliver my scripts only to the visitors that can use them.
If you set up your pages to run basic HTML, and limit the built in events to hyperlink navigation and server based forms, any page can display in any browser. Any other events can be built in scripts, and you can restrict the visitors who load the scripts to the folks who can use them. To each according to his ability.
In HTML, before the W3 put the kibosh on the language attribute, you
could screen the browsers by setting a version number of the language in the script tag:
<script language="JavaScript1.5" src="srcfile.js"></script>
This would prevent a browser that didn't support version1.5 from loading the file.
You could get fancier, and load different scripts for various levels of support:
<script language="JavaScript" src="srcfile1.js"></script>
<script language="JavaScript1.2" src="srcfile2.js"></script>
<script language="JavaScript1.5" src="srcfile3.js"></script>
Scripts here are cumulative. The first script loads in any browser that
supports the src attribute for external scripts. If number 3 loads,
you can count on having the first two as well. Each can have an onload handler--the
last handler assigned will be used when everything finally loads.
I wrote a lot of code like this, back when. But no more.
| home / programming / javascript / domloader | [next] |
Created: April 30, 2002
Revised: April 30, 2002
URL: http://webreference.com/programming/javascript/domloader/