JavaScript isNaN() 函数
返回 JavaScript 全局对象参考手册
定义和用法
isNaN() 函数用于检查其参数是否是非数字值。
语法
isNaN(x)
参数描述
x
必需。要检测的值。
返回值
如果 x 是特殊的非数字值 NaN(或者能被转换为这样的值),返回的值就是 true。如果 x 是其他值,则返回 false。
说明
isNaN() 函数可用于判断其参数是否是 NaN,该值表示一个非法的数字(比如被 0 除后得到的结果)。
如果把 NaN 与任何值(包括其自身)相比得到的结果均是 false,所以要判断某个值是否是 NaN,不能使用 == 或 === 运算符。正因为如此,isNaN() 函数是必需的。
提示和注释
提示:isNaN() 函数通常用于检测 parseFloat() 和 parseInt() 的结果,以判断它们表示的是否是合法的数字。当然也可以用 isNaN() 函数来检测算数错误,比如用 0 作除数的情况。
实例
在本例中,我们将使用 isFinite() 在检测无穷数:
<script type="text/javascript">
document.write(isFinite(123)) //返回 false
document.write(isFinite(-1.23)) //返回 false
document.write(isFinite(5-2)) //返回 false
document.write(isFinite(0)) //返回 false
document.write(isFinite(0/0)) //返回 true
document.write(isFinite("Hello")) //返回 true
document.write(isFinite("2005/12/12")) //返回 true
document.write(isFinite(true)) //返回 false
document.write(isFinite(undefined)) //返回 true
</script>
相关文档:
javascript:void(0)
刚开始都不知道是啥意思
其实就是一个死链接,什么事情都不做。
<a id="link_${user.account}" href="javascript:void(0);" onclick="changSubmit();" style="cursor:pointer;height:25px;width:60px;margin-top:10px;">发送email</a>
这句 ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>vForm表单验证程 ......
//后台CS调用前台JS方法
ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script>CheckInput()</script>");
//校验输入框是否为空,校验是否是数字
<script type="text/javascript" language="javascript">
function CheckInput ......
Javascript刷新页面的几种方法:
1 history.go(0)
2 location.reload()
3 location=location
4 location.assign(location)
5 document.execCommand('Refresh')
6 window.navigate(location)
7& ......
定义与用法
The prototype property allows you to add properties and methods to an
object.
prototype属性允许你向一个对象添加属性和方法
Syntax
语法
object.prototype.name=value
Example 1
实例
In this example we will show how to use the prototype property to add a
property to an object:
在下 ......