pc端js常用方法
程序员文章站
2022-04-09 18:03:43
var common = {}; /** * [pageMask ajax统一请求] * @return {[type]} [description] */ common.pageMask = function() { $.ajaxSetup({ beforeSend: function(xhr) ... ......
var common = {}; /** * [pagemask ajax统一请求] * @return {[type]} [description] */ common.pagemask = function() { $.ajaxsetup({ beforesend: function(xhr) { utils.mask(); }, complete: function(xhr, status) { utils.removemask(); } }); }; /** * [export form表单提交 导出功能] * @param {[type]} url [description] * @param {[type]} name [description] * @param {[type]} param [description] * @return {[type]} [description] */ common.export = function(url, name, param) { var form = $("<form></form>"); form.attr('action', url); form.attr('method', 'post'); for (var key in param) { var input = $('<input type="hidden" name="' + key + '" />'); input.val(param[key]); form.append(input); }; form.appendto("body"); form.css('display', 'none'); form.submit(); form.remove(); }; // 获取url中的中文值 common.getquerystring = function(name) { var reg = new regexp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) { return decodeuri(r[2]); } return ''; }; /** * [tothousands 数字格式处理,每三位加逗号] * @param {[type]} num [description] * @return {[type]} [description] */ common.tothousands: function(num) { var result = '', counter = 0; num = (num || 0).tostring(); for (var i = num.length - 1; i >= 0; i--) { counter++; result = num.charat(i) + result; if (!(counter % 3) && i != 0) { result = ',' + result; } } return result; }; /** * [getcurrenttime 获取当前时间] * @return {[type]} [description] */ common.getcurrenttime = function() { var now = new date(), year = now.getfullyear(), //获取年 month = now.getmonth() + 1, //获取月 date = now.getdate(), //获取日 hours = now.gethours(), //获取时 minutes = now.getminutes(), //获取分 second = now.getseconds(); // 获取秒 var currenttime = { year: year, month: month < 10 ? '0' + month : month, //一位数补0 day: date < 10 ? '0' + date : date, hours: hours < 10 ? '0' + hours : hours, minutes: minutes < 10 ? '0' + minutes : minutes, second: second < 10 ? '0' + second : second }; return currenttime; };
上一篇: 招商基金笔试题
下一篇: 设计模式之外观模式——Java语言描述