Analysis of javascript Functions used in discuz [original] Page 1/2 _ javascript skills
Source: Internet
Author: User
The js used in discuz is very good in compatibility and practicability of multiple browsers. We recommend you read var lang = new Array ();
Var userAgent = navigator. userAgent. toLowerCase ();
Var is_opera = userAgent. indexOf ('Opera ')! =-1 & opera. version ();
Var is_moz = (navigator. product = 'gecko ') & userAgent. substr (userAgent. indexOf ('Firefox') + 8, 3 );
Var is_ie = (userAgent. indexOf ('msie ')! =-1 &&! Is_opera) & userAgent. substr (userAgent. indexOf ('msie ') + 5, 3 );
Function $ (id ){
Return document. getElementById (id );
}
// Define the push attribute of the array
Array. prototype. push = function (value ){
This [this. length] = value;
Return this. length;
}
// Select all functions in javascript
Function checkall (form, prefix, checkall ){
Var checkall = checkall? Checkall: 'chall ';
For (var I = 0; I <form. elements. length; I ++ ){
Var e = form. elements [I];
If (e. name & e. name! = Checkall &&(! Prefix | (prefix & e. name. match (prefix )))){
E. checked = form. elements [checkall]. checked;
}
}
}
Function doane (event ){
E = event? Event: window. event;
If (is_ie ){
E. returnValue = false;
E. cancelBubble = true;
} Else if (e ){
E. stopPropagation ();
E. preventDefault ();
}
}
Function in_array (needle, haystack ){
If (typeof needle = 'string' | typeof needle = 'number '){
For (var I in haystack ){
If (haystack [I] = needle ){
Return true;
}
}
}
Return false;
}
Function setcopy (text, alertmsg ){
If (is_ie ){
ClipboardData. setData ('text', Text );
Alert (alertmsg );
} Else if (prompt ('Press Ctrl + C Copy to clipboard', text )){
Alert (alertmsg );
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.