加入收藏 | 设为首页 | 会员中心 | RSS
您当前的位置:首页 > 技术在线 > Asp

用ASP CSS实现随机背景

时间:2008-06-11 07:45:28  来源:fifty   作者:

随机背景--当你每次进入该页面时,从已指定的图片文件夹中,随机选取一个图片作为背景显示。这里介绍的方法是用ASP CSS来实现的。

ASP

以下是引用片段:Const IMGS_DIR = "/images"

'设定图片文件夹的地址,随机显示该文件夹内任一张图片

以下为引用的内容:

Dim objFSO, objFolderObject, objFileCollection, objFile
Dim intFileNumberToUse, intFileLooper
Dim objImageFileToUse
Dim strImageSrcText
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolderObject = objFSO.GetFolder(Server.MapPath(IMGS_DIR))
Set objFSO = Nothing
Set objFileCollection = objFolderObject.Files
Set objFolderObject = Nothing
Randomize()
intFileNumberToUse = Int(objFileCollection.Count * Rnd) 1
intFileLooper = 1
For Each objFile in objFileCollection
If intFileLooper = intFileNumberToUse Then
Set objImageFileToUse = objFile
Exit For
End If
intFileLooper = intFileLooper 1
Next Set objFileCollection = Nothing
strImageSrcText = IMGS_DIR

来顶一下
近回首页
返回首页
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
推荐资讯
消息称雅虎和谷歌或于下周推开放广告平台
消息称雅虎和谷歌或于
成功的站长应是全才
成功的站长应是全才
探秘Google数据中心:运行服务器远超20万台
探秘Google数据中心:
地震中的程序人生-《疯狂的程序员》作者绝影
地震中的程序人生-《
相关文章
    无相关信息
栏目更新
栏目热门
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助