/*********************************************/ /* trim the both side blank of the string */ /*********************************************/ function trim(s) { return trimright(trimleft(s)); } /****************************************/ /* trim the left blank of the string */ /****************************************/ function trimleft(s) { while (s.charat(0) ==" " ||s.charat(0) =="" ){ s = s.substr(1,s.length-1); } return s; } /*****************************************/ /* trim the right blank of the string */ /*****************************************/ function trimright(s) { while (s.charat(s.length-1) == " " || s.charat(s.length-1) == "") { s = s.substr(0,s.length-1); } return s; } /** * 获取窗体高度 */ function getwindowheight() { var windowheight = 0; if (typeof (window.innerheight) == "number") { windowheight = window.innerheight; } else { if (document.documentelement && document.documentelement.clientheight) { windowheight = document.documentelement.clientheight; } else { if (document.body && document.body.clientheight) { windowheight = document.body.clientheight; } } } return windowheight; } /** * 获取窗体宽度 */ function getwindowwidth() { var windowwidth = 0; if (typeof (window.innerwidth) == "number") { windowwidth = window.innerwidth; } else { if (document.documentelement && document.documentelement.clientwidth) { windowwidth = document.documentelement.clientwidth; } else { if (document.body && document.body.clientwidth) { windowwidth = document.body.clientwidth; } } } return windowwidth; } /************************ jquery **************************/ /** * 使用ajax提交数据 */ function ajax_post(the_url,the_param,succ_callback){ jquery.ajax({ type:'post', url:the_url, data:the_param, success:succ_callback, error:function(html){ var flag = (typeof console != 'undefined'); if(flag) console.log("服务器忙,提交数据失败,代码:" +html.status+ ",请联系管理员!"); //alert("服务器忙,提交数据失败,代码:" +html.status+ ",请联系管理员!"); } }); } /** * 避免传递空""值过来value时判断为是取值操作而不是赋值操作 */ function jqname(name,value){ if(value === undefined) { return jquery(":input[name='"+name+"']").val()||''; }else{ return jquery(":input[name='"+name+"']").val(value); } } /************************** form处理 *****************************/ /** * 重置表单 */ function resetform(){ $(".tablesearch input:not(.btn1)").val(""); $(".tablesearch select").val("-1"); } function console_log(str){ var flag = (typeof console != 'undefined'); if(flag) console.log('flyfox--> '+str); } /////////////////////////bootstrap 扩展//////////////////////////// var modal = { iframe:function (url,height,title){ title = title || '信息'; height = height || '450'; $('#modal-iframe').attr("src",url); $('#modal-iframe').height(height); $('.modal #mymodallabel').html(title); $('#mymodal').modal('show'); } };