★★★★★ 今天发现了微软的一个BUG,很是奇怪,不知道大家见过没有!★★★★★
windows2000 Professional
IE 6.0
先看下面一段JavaScript代码:
<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JScript">
<!--
function test()
{
document.write(parseInt("01"));
document.write(parseInt("02"));
document.write(parseInt("03"));
document.write(parseInt("04"));
document.write(parseInt("05"));
document.write(parseInt("06"));
document.write(parseInt("07"));
document.write(parseInt("08"));
document.write(parseInt("09"));
document.write(parseInt("10"));
}
// -->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<input type="button" name="Submit" value="按钮" OnClick="test()">
</form>
</body>
</html>
显示的结果为:12345670010
奇怪吧,但是在Opera中显示的却是对的,IE6,5,4中均显示错误值
解决方案:把parseInt换为parseFloat就是对的,或者把01,02,03前面的0去掉也行
不知道微软这个函数是怎么写的,大家可以试试看呀。