您当前的位置:中客资源站网络学院网页设计HTML/CSS → 文章内容 退出登录 用户管理
本类热门文章
相关下载
用ASP CSS实现随机背景
作者:本站整理  来源:站长网  发布时间:2007-5-20 4:51:09

减小字体 增大字体

随机背景--当你每次进入该页面时,从已指定的图片文件夹中,随机选取一个图片作为背景显示。这里介绍的方法是用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


[] [返回上一页] [打 印]
文章评论 (评论内容只代表网友观点,与本站立场无关!)

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码