20、随机乱码生成器

20、随机乱码生成器

要完成此效果把如下代码加入到<body>区域中

 

<SCRIPT>

 

function scram(v)

{

if(v>20){alert("Too many symbols, change "+v+" to a lesser value, 20 or under.");document.cow.noyey.focus()}

else

{

i=0

str=""

while(i<v)

 

{

x=Math.round(Math.random()*100)

 

if(x<33 || x>255){}

else{

i++

str+=String.fromCharCode(x)

}}

document.cow.noy.value=str

}}

</SCRIPT>

<FORM name="cow">

随机的字符:<INPUT TYPE="Text" name="noy" value="" size="20" onFocus="this.blur()"><br>

请输入字符?(max 20):<INPUT TYPE="Text" name="noyey" value="20" size="4"><br>

<input type="button" onClick="scram(noyey.value)" value="产生文字">

<INPUT TYPE="reset">

</FORM>

 

 

Write a comment

Comments: 0