Javascript 生成随机数

内容纲要

简单的生成随机数:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script type="text/javascript">
function Randnum(value){
  var s=1000;
  var d=500;
  if(value=='b'){
    document.write(s+parseInt(500*Math.random()));
  }else{
    document.write(d+parseInt(500*Math.random()));
  }
}
</script>
<script>Randnum();</script>
</body>
</html>


发表评论

您的电子邮箱地址不会被公开。