var singoocms = new object(); function submitkeyclick(button) { if (event.keycode == 13) { event.keycode = 9; event.returnvalue = false; document.all[button].click(); } } function checkalls(who, form) { for (var i = 0; i < form.elements.length; i++) { var e = form.elements[i]; if (e.type == "checkbox" && e.disabled == false) e.checked = who.checked; } } function checkgridviewall(controlchbox, parentid) { var control = document.getelementbyid(controlchbox); //主控 checkbox var table = document.getelementbyid(parentid); //范围标签 var inputelement = table.getelementsbytagname("input"); if (inputelement.length > 0) { for (var i = 0; i < inputelement.length; i++) { if (inputelement[i].type == "checkbox" && inputelement[i].disabled == false) inputelement[i].checked = controlchbox.checked; //范围内的checkbox适应于主控checkbox } } } //window.onerror = function(){return true}; function addfavorite(surl, stitle) { try { window.external.addfavorite(surl, stitle); } catch (e) { try { window.sidebar.addpanel(stitle, surl, ""); } catch (e) { alert("加入收藏失败,请使用ctrl+d进行添加"); } } } function sethome(obj, surl) { try { obj.style.behavior = 'url(#default#homepage)'; obj.sethomepage(surl); } catch (e) { if (window.netscape) { try { netscape.security.privilegemanager.enableprivilege("universalxpconnect"); } catch (e) { alert("此操作被浏览器拒绝!"); } var prefs = components.classes['@mozilla.org/preferences-service;1'].getservice(components.interfaces.nsiprefbranch); prefs.setcharpref("browser.startup.homepage", surl); } } } function copytoclipboard(txt) { if (window.clipboarddata) { window.clipboarddata.cleardata(); window.clipboarddata.setdata("text", txt); } else if (navigator.useragent.indexof("opera") != -1) { window.location = txt; } else if (window.netscape) { try { netscape.security.privilegemanager.enableprivilege("universalxpconnect"); } catch (e) { alert("被浏览器拒绝!\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'"); } var clip = components.classes['@mozilla.org/widget/clipboard;1'].createinstance(components.interfaces.nsiclipboard); if (!clip) return; var trans = components.classes['@mozilla.org/widget/transferable;1'].createinstance(components.interfaces.nsitransferable); if (!trans) return; trans.adddataflavor('text/unicode'); var str = new object(); var len = new object(); var str = components.classes["@mozilla.org/supports-string;1"].createinstance(components.interfaces.nsisupportsstring); var copytext = txt; str.data = copytext; trans.settransferdata("text/unicode", str, copytext.length * 2); var clipid = components.interfaces.nsiclipboard; if (!clip) return false; clip.setdata(trans, null, clipid.kglobalclipboard); alert("复制成功!") } } string.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); } string.prototype.ltrim = function () { return this.replace(/(^\s*)/g, ""); } string.prototype.rtrim = function () { return this.replace(/(\s*$)/g, ""); } string.prototype.alltrim = function () { return this.replace(/\s+/g, ""); } string.prototype.endwith = function (str) { if (str == null || str == "" || this.length == 0 || str.length > this.length) return false; if (this.substring(this.length - str.length) == str) return true; else return false; } string.prototype.startwith = function (str) { if (str == null || str == "" || this.length == 0 || str.length > this.length) return false; if (this.substr(0, str.length) == str) return true; else return false; } string.prototype.replaceall = function (s1, s2) { return this.replace(new regexp(s1, "gm"), s2); } //判断是否图片文件 string.prototype.ispicture = function () { //判断是否是图片 - strfilter必须是小写列举 var strfilter = ".jpeg|.gif|.jpg|.png|.bmp|" if (this.indexof(".") > -1) { var p = this.lastindexof("."); var strpostfix = this.substring(p, this.length) + '|'; strpostfix = strpostfix.tolowercase(); ; if (strfilter.indexof(strpostfix) > -1) { return true; } } return false; } function showmsg(msg) { $.dialog({ title: '系统提示', content: msg, width: 260, height: 60, lock: false }) } function showalert(msg) { $.dialog({ title: '系统提示', content: msg, width: 260, height: 60, icon: 'warning', lock: false }) } function showsuccess(msg) { $.dialog({ title: '系统提示', content: msg, width: 260, height: 60, icon: 'succeed', lock: false }) } function showtip(msg) { $.dialog.tips(msg, 3); } function showimg(imgsrc) { if (imgsrc == null || imgsrc == "") showalert("没有找到图片"); else if (!imgsrc.ispicture()) showalert("非图片格式"); else $.dialog({ padding: 0, title: '查看图片', content: '', lock: false }); } $(function () { if ($("table").hasclass("stripe_tb")) { $(".stripe_tb tr").mouseover(function () { //如果鼠标移到class为stripe_tb的表格的tr上时,执行函数 $(this).addclass("over"); }).mouseout(function () { //给这行添加class值为over,并且当鼠标一出该行时执行函数 $(this).removeclass("over"); }) //移除该行的class $(".stripe_tb tr:even").addclass("alt"); $(".stripe_tb tr").click(function () { $(".stripe_tb tr").removeclass("click"); $(this).addclass("click"); }); $(".stripe_tb tr").dblclick(function () { $(this).removeclass("click"); }); } }); //20120424 add var s = ""; //查询参数字符串 var request = {}; //初始化request对象 function initrequest() { s = location.search; var m, reg = /([a-z\d]+)=([^&]+)/gi; s = s == '' ? '' : s.substring(1); while (m = reg.exec(s)) request[m[1].tolowercase()] = m[2]; //添加项进入hash对象 } //列宽自由拖动 /* $(document).ready(function () { var gridviewtable = document.getelementbyid("ctl00_contentplaceholder1_gridview1"); if (gridviewtable != null) new table("ctl00_contentplaceholder1_gridview1"); });*/ /* 调用方法 singoocms.post('/shop/addtocart.aspx', { _protype: '普通订购', _pid:'${item.autoid}', _buynumber: 1, _price: '$price1' }); */ singoocms.post = function (url, params) { var temp = document.createelement("form"); temp.action = url; temp.method = "post"; temp.style.display = "none"; for (var x in params) { var opt = document.createelement("textarea"); opt.name = x; opt.value = params[x]; temp.appendchild(opt); } document.body.appendchild(temp); temp.submit(); return temp; } //获取一个毫秒+2位附加码的随机数 function getrnd() { var now = new date(); return now.getseconds() + "" + now.getmilliseconds() + "" + math.ceil(math.random() * 10); //获取当前毫秒+随机数 } //获取一组 单选/复选表单的值 function getids(elementname) { var ids = ""; jquery.each(jquery("input[name='" + elementname + "']"), function (index, item) { if (item.checked) ids += jquery(item).val() + ","; }); return ids; } //日期格式化 date.prototype.format = function (format) { var o = { "m+": this.getmonth() + 1, //month "d+": this.getdate(), //day "h+": this.gethours(), //hour "m+": this.getminutes(), //minute "s+": this.getseconds(), //second "q+": math.floor((this.getmonth() + 3) / 3), //quarter "s": this.getmilliseconds() //millisecond } if (/(y+)/.test(format)) { format = format.replace(regexp.$1, (this.getfullyear() + "").substr(4 - regexp.$1.length)); } for (var k in o) { if (new regexp("(" + k + ")").test(format)) { format = format.replace(regexp.$1, regexp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); } } return format; }