[thelist] Pontification on object and method detection (was: Wanted: thedefi
Peter-Paul Koch
gassinaumasis at hotmail.com
Fri Jun 29 05:29:11 CDT 2001
>Joe Crawford wrote:
> > Still, /intuitively/ if you're going to use an object, you should test
>for the object.
<applause>
Yes!
</applause>
> > But the problem I have, is that it is so very /tied/ to a peculiarity of
>how the <script> tag works.
>
>However, even with my limited experience, I wouldn't say that
>the pair of scripts is exploiting a *peculiarity* of the
>script tag. My understanding is that the language version
>in the script tag is *meant* to be used to tell browsers which
>scripts they should attempt running.
That is true, but you shouldn't rely on version numbers. For instance,
Netscape 4 and Explorer 4 both support JavaScript 1.3 (1.2 in old versions),
but nonetheless even the biggest imagination can't maintain that they
support the same JavaScript. Therefore I don't find the JavaScript versions
helpful at all and I never use them.
>My first script will always run in all JS-enabled browsers -
>the second will (okay, should) only run in browsers that
>implement JS 1.1 or above. "if (document.images)" tests
>for a specific object - this new pair of scripts tests for
>a minimum JS language version. Different test, same result
>for plain ol' mouseover code.
I think IE3 formally supports 1.1 (but I'm not sure). Anyway, this may work
for mouseovers, but it an get you in trouble with other scripts.
Unfortunately, since I've never used versions, I can't give an example, but
I wouldn't rely on something so unimportant as the version number. After
all, the programmers can simply tweak the browser to let it accept 1.4 while
not changing the code engine that interprets JavaScript.
The version number simply does not have a direct relation with the supported
objects and methods, while object/method detection does.
ppk
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
More information about the thelist
mailing list