原理很简单,就是随机在字典中取字符,然后把取出来的字符连接起来形成一个文件名。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>随机文件名</title> </head> <body> <script type="text/vbscript" language="vbscript"> <!-- function CreateRndFileIden(fileIdenLen) const dic = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" '用于产生文件名的字典 randomize dim i, r for i = 1 to fileIdenLen r = Fix(Rnd()*Len(dic)) + 1 CreateRndFileIden = CreateRndFileIden & Mid(dic, r, 1) '每次从字典中随机取一个字符 next end function document.write(CreateRndFileIden(16) & ".htm") --> </script> </body> </html>[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
创建于2005年 渝ICP备05010272号-1
电邮:cftea@126.com