Introducing the class Util. Its a metling pot of methods that can be very usefull at any time when programming javascript. Theses methods are not meant for a particular type of object. For example, the dollar function ($) which is a shorthand for document.getElementById is not part of the Util class. It is in the Dom class as it plays with DOM Elements.
Here are some methods :
//A shorthand for document.write
Util.dw = function(str) {
document.write(str);
}
//You can alert multiple arguments send to that function
Util.alert = function() {
var str = '';
for (var i=0; i< arguments.length; i++) {
str += arguments[i];
if ( i != arguments.length-1 )
str += ' / ';
}
alert(str);
}
13 December, 2005
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment