用ASP CSS实现随机背景
核心提示:随机背景--当你每次进进该页面时,从已指定的图片文件夹中,随机选取1个图片作为背景显示。这里先容的方法是用ASP CSS来实现的。
随机背景--当你每次进进该页面时,从已指定的图片文件夹中,随机选取1个图片作为背景显示。这里先容的方法是用ASP CSS来实现的。
ASP
以下是援用片断:Const IMGS_DIR = "/images"
'设定图片文件夹的地址,随机显示该文件夹内任1张图片
以下为援用的内容:
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
|
http://www.fw8.net/TAG:
图片,
文件,
文件夹,
页面,
背景