discuz中用到的javascript函数解析[原创]第1/2页_javascript技巧
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了discuz中用到的javascript函数解析[原创]第1/2页_javascript技巧,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3032字,纯文字阅读大概需要5分钟。
内容图文
![discuz中用到的javascript函数解析[原创]第1/2页_javascript技巧](/upload/InfoBanner/zyjiaocheng/308/9a4667555a944e3b907eb1600e1ae71f.jpg)
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);
}
//定义数组的push属性
Array.prototype.push = function(value) {
this[this.length] = value;
return this.length;
}
//javascript全选函数
function checkall(form, prefix, checkall) {
var checkall = checkall ? checkall : 'chkall';
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 fetchCheckbox(cbn) {
return $(cbn) && $(cbn).checked == true ? 1 : 0;
}
function getcookie(name) {
var cookie_start = document.cookie.indexOf(name);
var cookie_end = document.cookie.indexOf(";", cookie_start);
return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
}
function thumbImg(obj) {
var zw = obj.width;
var zh = obj.height;
if(is_ie && zw == 0 && zh == 0) {
var matches;
re = /width=(["']?)(\d+)(\1)/i;
matches = re.exec(obj.outerHTML);
zw = matches[2];
re = /height=(["']?)(\d+)(\1)/i;
matches = re.exec(obj.outerHTML);
zh = matches[2];
}
obj.resized = true;
obj.style.width = zw + 'px';
obj.style.height = 'auto';
if(obj.offsetHeight > zh) {
obj.style.height = zh + 'px';
obj.style.width = 'auto';
}
if(is_ie) {
var imgid = 'img_' + Math.random();
obj.id = imgid;
setTimeout('try {if ($(\''+imgid+'\').offsetHeight > '+zh+') {$(\''+imgid+'\').style.height = \''+zh+'px\';$(\''+imgid+'\').style.width = \'auto\';}} catch(e){}', 1000);
}
obj.onload = null;
}
function imgzoom(obj) {}
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);
}
}
function isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function mb_strlen(str) {
var len = 0;
for(var i = 0; i < str.length; i++) {
len += str.charCodeAt(i)
内容总结
以上是互联网集市为您收集整理的discuz中用到的javascript函数解析[原创]第1/2页_javascript技巧全部内容,希望文章能够帮你解决discuz中用到的javascript函数解析[原创]第1/2页_javascript技巧所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。