<p> 随机背景--当你每次进入该页面时,从已指定的图片文件夹中,随机选取一个图片作为背景显示。这里介绍的方法是用ASP+CSS来实现的。</p><p> ASP代码</p><code>Const IMGS_DIR = "/images" '设定图片文件夹的地址,随机显示该文件夹内任一张图片 Dim objFSO, objFolderObject, objFileCollection, objFile<br />Dim intFileNumberToUse, intFileLooper<br />Dim objImageFileToUse<br />Dim strImageSrcText<br />Set objFSO = Server.CreateObject("Scripting.FileSystemObject")<br />Set objFolderObject = objFSO.GetFolder(Server.MapPath(IMGS_DIR))<br />Set objFSO = Nothing<br />Set objFileCollection = objFolderObject.Files<br />Set objFolderObject = Nothing<br />Randomize()<br />intFileNumberToUse = Int(objFileCollection.Count * Rnd) + 1<br />intFileLooper = 1<br />For Each objFile in objFileCollection<br />If intFileLooper = intFileNumberToUse Then<br />Set objImageFileToUse = objFile<br />Exit For<br />End If<br />intFileLooper = intFileLooper + 1<br />Next<br />Set objFileCollection = Nothing<br />strImageSrcText = IMGS_DIR & objImageFileToUse.Name<br />Set objImageFileToUse = Nothing</code></p><p> CSS代码</p><code>#pic{<br /> width:400px;<br /> height:300px;<br /> background:url(<%=strImageSrcText%>)no-repeat;<br /> margin:2emauto;<br />}</code></p>