秋水的代码:<script>
function qswhDiv(p1,p2){
var t1=0,t2=0,r1,r2;
try{t1=p1.toString().split(".")[1].length}catch(e){}
try{t2=p2.toString().split(".")[1].length}catch(e){}
with(Math){
r1=p1*pow(10,t1)
r2=p2*pow(10,t2)
return (r1/r2)*pow(10,t2-t1);
}
}
alert(qswhDiv(19879,19.879))
alert(qswhDiv(19999,199.99))
</script>或者用vbscript alert (19879/19.879);
execScript('alert(19879/19.879)','vbscript')
function qswhDiv(p1,p2){
var t1=0,t2=0,r1,r2;
try{t1=p1.toString().split(".")[1].length}catch(e){}
try{t2=p2.toString().split(".")[1].length}catch(e){}
with(Math){
r1=p1*pow(10,t1)
r2=p2*pow(10,t2)
return (r1/r2)*pow(10,t2-t1);
}
}
alert(qswhDiv(19879,19.879))
alert(qswhDiv(19999,199.99))
</script>或者用vbscript alert (19879/19.879);
execScript('alert(19879/19.879)','vbscript')
解决方案 »
- 上线问题,紧急求助!!!history.go(-1)和iframe的问题
- javascript 如何在一个标记中间插入文本?如在<div>插入文本</div>
- 怎么js设置Img的宽度,和高度?
- IE9之前这样调用JS文件内函数无问题到了IE10就用打开兼容模式才可以了?
- 为什么这个树型菜单初始状态是打开状态,而不是收缩状态(有相关代码)
- javascript控制打印边框
- 如何在一个html中调用一个word文件
- 怎样用一个按钮切换一个文本输入框的可用和不可用
- 高手请进,急急急!!!(我写了一个web版的oicq,但遇到了一些问题...)
- 修改一个优秀的相对定位层在表格范围内拖动的代码
- 有关outerhtml的问题,很急,在线等待!!!
- 怎样判断字符串?
toFixed() Method
Returns a string representing a number in fixed-point notation.numObj.toFixed([fractionDigits])Arguments
numObjRequired A Number object.fractionDigitsOptional. Number of digits after the decimal point. Must be in the range 0 – 20, inclusive.Res
The toFixed method returns a string representation of a number in fixed-point notation. The string contains one digit before the significand's decimal point, and must contain fractionDigits digits after it. If fractionDigits is not supplied or undefined, the toFixed method assumes the value is zero.Requirements
Version 5.5