站 内 搜 索
推 荐 合 作 商
优 秀 内 容 推 荐
  您当前位置:中国素材首页 >> 网页特效 >> 数学类 >> 职位
 
职位
中国素材网 www.sucai.com 2005-3-31 13:03:00 流量数:

职位
[查看演示]  源码如下
----------------------------------------------------------------------------------------
<style>body,td,div,a,input,xmp{font:menu}</style>
<script>
function tofloat(f,dec)
{
if(dec<0) return "Error:dec<0!";
result=parseInt(f)+(dec==0?"":".");
f-=parseInt(f);
if(f==0)
for(i=0;i<dec;i++)
result+='0';
else
{
for(i=0;i<dec;i++)
f*=10;
result+=parseInt(Math.round(f));
}
return result;
}
window.status=tofloat(11.20000000000000000001,5);</script>
检查一段字符串是否全由数字组成,如果是,返回true 如果否,返回false

<xmp>
<script>
function checkNum(str){
return str.match(/\D/)==null
}
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
</script>
</xmp>
<xmp>
<script language=javascript><!--
function StrCh(str){
var s;
for (i = 0; i < str.length; i++){
s = str.charCodeAt(i);
if (!((s>=48) && (s<= 57))) return false;
}
return true;
}
if(StrCh("124182787"))alert("true");
if(!StrCh("28980OOP"))alert("false");
// --></script>
</xmp>

<div style="position: absolute; top: 10; right: 10; width: 148; height: 18;cursor:hand">
<input type="button" name="Button" value="查看源代码" onClick= 'window.location = "view-source:" + window.location.href'></div>