yuezhonghu

悠然现南山...
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

实用JS 函数

Posted on 2008-04-01 12:29  .狐狸血.  阅读(123)  评论(0编辑  收藏  举报

保留小数点 的位数(四舍五入) 
toFixed(n) : 参数  n 保留的位数

转换为数字
Number(n) : 参数 n 要转换的对象

判断非法字符
isNaN(n) :参数 n 判断对象 

选择上传图片出预览效果的JS  :
<input id="file_index" runat="server" type="file" onpropertychange="javascript:showImg(this);" />
程序
function showImg(path)
{
var upload=path;
document.getElementById("Image1").src=upload.value;
}

判断是否为空null
isNull(n):参数 n判断对象

注意:在JS语言中如下是错误的 判断 if(n==null)执行...  
     正确判断 if(isNull(n)) 执行...

JS弹出式网页(如果不关闭此页,无法进行下一步)
var retval = window.showModalDialog('要弹出的页面.htm', null, 'dialogWidth:250px;dialogHeight: 440px;help:0;scroll:0;status:0');