无为清净楼资源网 Design By www.qnjia.com
Js获取页面地址参数
复制代码 代码如下:
function getUrlPara(paraName)
{
var sUrl = location.href;
var sReg = "(?://?|&){1}" + paraName + "=([^&]*)"
var re = new RegExp(sReg, "gi");
re.exec(sUrl);
return RegExp.$1;
}
地址跳转
复制代码 代码如下:
var pn = $("#gotopagenum").val();//#gotopagenum是文本框的id属性
location.href = "NewList.aspx?pagenum="+pn;//location.href实现客户端页面的跳转
千分位
复制代码 代码如下:
function Convert(money)
{
var s = money; //获取小数型数据
s += "";
if (s.indexOf(".") == -1) s += ".00"; //如果没有小数点,在后面补个小数点和00
if (/\.\d$/.test(s)) s += "0"; //正则判断
while (/\d{4}(\.|,)/.test(s)) //符合条件则进行替换
s = s.replace(/(\d)(\d{3}(\.|,))/, "$1,$2"); //每隔3位添加一个
return s;
}
判断是否数字
复制代码 代码如下:
function IsNumeric(txt) {
if (txt == "") {
return false;
}
if (txt.indexOf(",") > 0) {
txt = txt.replace(",", "");
}
if (isNaN(txt)) {
return false;
}
else {
return true;
}
}
将数字进行两位小数的格式化
复制代码 代码如下:
function changeTwoDecimal_f(x) {
var f_x = parseFloat(x);
if (isNaN(f_x)) {
alert('function:changeTwoDecimal->parameter error');
return false;
}
f_x = Math.round(f_x * 100) / 100;
var s_x = f_x.toString();
var pos_decimal = s_x.indexOf('.');
if (pos_decimal < 0) {
pos_decimal = s_x.length;
s_x += '.';
}
while (s_x.length <= pos_decimal + 2) {
s_x += '0';
}
return s_x;
}
Js 进行数字运算的函数 parseFloat parseInt
js 当前日期 yyyy-mm-dd 预置查询条件
复制代码 代码如下:
var now = new Date();
var year = now.getYear();
if (now.getYear() < 1900) {
year = now.getYear() + 1900;
}
var month = now.getMonth() + 1;
var day = now.getDate();
if (month < 10) month = "0" + month;
if (day < 10) day = "0" + day;
$("#txtDate1").val(year.toString() + "-" + month.toString() + "-01");
$("#txtDate2").val(year.toString() + "-" + month.toString() + "-" + day.toString());
Js 获取时间戳,在某些情景下代替Guid
复制代码 代码如下:
function NowTimeCode()
{
var Result="";
var now = new Date();
var year = now.getYear();
if (now.getYear() < 1900) {
year = now.getYear() + 1900;
}
var month = now.getMonth() + 1;
var day = now.getDate();
var hour = now.getHours();
var minutes = now.getMinutes();
var second = now.getSeconds();
var millisecond = now.getMilliseconds();
if (month < 10) month = "0" + month;
if (day < 10) day = "0"+ day;
if (hour < 10) hour = "0"+ hour;
if (minutes < 10) minutes = "0"+ minutes;
if (second < 10) second = "0"+ second;
if (millisecond < 10)
millisecond = "00"+ millisecond;
else
{
if (millisecond < 100)
{
millisecond = "0"+ millisecond;
}
}
Result = year.toString() + month.toString() + day.toString() + hour.toString() + minutes.toString() + second.toString() + millisecond.toString();
return Result;
}
复制代码 代码如下:
function getUrlPara(paraName)
{
var sUrl = location.href;
var sReg = "(?://?|&){1}" + paraName + "=([^&]*)"
var re = new RegExp(sReg, "gi");
re.exec(sUrl);
return RegExp.$1;
}
地址跳转
复制代码 代码如下:
var pn = $("#gotopagenum").val();//#gotopagenum是文本框的id属性
location.href = "NewList.aspx?pagenum="+pn;//location.href实现客户端页面的跳转
千分位
复制代码 代码如下:
function Convert(money)
{
var s = money; //获取小数型数据
s += "";
if (s.indexOf(".") == -1) s += ".00"; //如果没有小数点,在后面补个小数点和00
if (/\.\d$/.test(s)) s += "0"; //正则判断
while (/\d{4}(\.|,)/.test(s)) //符合条件则进行替换
s = s.replace(/(\d)(\d{3}(\.|,))/, "$1,$2"); //每隔3位添加一个
return s;
}
判断是否数字
复制代码 代码如下:
function IsNumeric(txt) {
if (txt == "") {
return false;
}
if (txt.indexOf(",") > 0) {
txt = txt.replace(",", "");
}
if (isNaN(txt)) {
return false;
}
else {
return true;
}
}
将数字进行两位小数的格式化
复制代码 代码如下:
function changeTwoDecimal_f(x) {
var f_x = parseFloat(x);
if (isNaN(f_x)) {
alert('function:changeTwoDecimal->parameter error');
return false;
}
f_x = Math.round(f_x * 100) / 100;
var s_x = f_x.toString();
var pos_decimal = s_x.indexOf('.');
if (pos_decimal < 0) {
pos_decimal = s_x.length;
s_x += '.';
}
while (s_x.length <= pos_decimal + 2) {
s_x += '0';
}
return s_x;
}
Js 进行数字运算的函数 parseFloat parseInt
js 当前日期 yyyy-mm-dd 预置查询条件
复制代码 代码如下:
var now = new Date();
var year = now.getYear();
if (now.getYear() < 1900) {
year = now.getYear() + 1900;
}
var month = now.getMonth() + 1;
var day = now.getDate();
if (month < 10) month = "0" + month;
if (day < 10) day = "0" + day;
$("#txtDate1").val(year.toString() + "-" + month.toString() + "-01");
$("#txtDate2").val(year.toString() + "-" + month.toString() + "-" + day.toString());
Js 获取时间戳,在某些情景下代替Guid
复制代码 代码如下:
function NowTimeCode()
{
var Result="";
var now = new Date();
var year = now.getYear();
if (now.getYear() < 1900) {
year = now.getYear() + 1900;
}
var month = now.getMonth() + 1;
var day = now.getDate();
var hour = now.getHours();
var minutes = now.getMinutes();
var second = now.getSeconds();
var millisecond = now.getMilliseconds();
if (month < 10) month = "0" + month;
if (day < 10) day = "0"+ day;
if (hour < 10) hour = "0"+ hour;
if (minutes < 10) minutes = "0"+ minutes;
if (second < 10) second = "0"+ second;
if (millisecond < 10)
millisecond = "00"+ millisecond;
else
{
if (millisecond < 100)
{
millisecond = "0"+ millisecond;
}
}
Result = year.toString() + month.toString() + day.toString() + hour.toString() + minutes.toString() + second.toString() + millisecond.toString();
return Result;
}
标签:
常用函数,JS函数
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年10月02日
2024年10月02日
- 纪钧瀚《钢琴阅读时光 雨中书店聆听轻音乐》[FLAC/分轨][399.62MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[320K/MP3][87.4MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[FLAC/分轨][184.94MB]
- 陈慧娴.2018-Priscilla-Ism演唱会3CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 郑秀文.1999-我应该得到(国)【华纳】【WAV+CUE】
- 陈家慧.2011-钢琴酒吧2CD【龙吟唱片】【WAV+CUE】
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[320K/MP3][45.01MB]
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[FLAC/分轨][109.13MB]
- 赞多《序章》[320K/MP3][45.54MB]
- 许巍.2004-每一刻都是崭新的【步升大风】【WAV+CUE】
- 群星.2024-四方馆影视原声带【韶愔音乐】【FLAC分轨】
- 陈雷.1997-安锁咧【金圆唱片】【WAV+CUE】
- 关淑怡.2013-MY.FAVORITE.SK.3CD【环球】【WAV+CUE】
- Sweety.2006-花言乔语【丰华】【WAV+CUE】
- 李恕权.2003-回·20年全精选2CD【SONY】【WAV+CUE】