JavaScript - prototype - check for browser compatibility

V

VK

> What is the best way to check, if prototype is running correctly?

prototype.js has its own author you should address your question to.

On an abstract level: "How to check that an external library loaded and
parsed properly?" you could choose some representative object from that
library and check its type.

if ("undefined" != typeof $) {
// prototype.js seems loaded OK
}
 
T

Thomas 'PointedEars' Lahn

> I am using the JavaScript prototype library
(http://prototype.conio.net/)

My sincere condolences.
and want to check if the library is running properly, because javascript
prototype is not supported by IE versions older than IE 6 (see
http://wiki.osafoundation.org/bin/view/Projects/AjaxLibraries).

That is an understatement. Prototype.js is much more restricted to certain
browsers than you think. Which is one of its many flaws.

It is possible to rewrite that code so that it runs with a wider spectrum
of HTML user agents, following design guidelines laid out in numerous
discussions in this newsgroup, and programming along the version
information known for each language feature[1]. However, I'd rather
rewrite it from scratch than to attempt to correct this junk.
What is the best way to check, if prototype is running correctly?

Always test the return values.[2] (With a `typeof' test you can only test
that a certain variable does not have the `undefined' value; it does not
test that the code invoked by calling that variable as a method will run
correctly. Incidentally, you should not trust anything VK is proposing.)


PointedEars
___________
[1] <URL:http://pointedears.de/es-matrix/>
[2] <URL:http://pointedears.de/scripts/test/whatami#inference>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top