国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

用ASP-+CSS實現隨機背景

2019-11-02 15:48:51
字體:
來源:轉載
供稿:網友

 隨機背景--當你每次進入該頁面時,從已指定的圖片文件夾中,隨機選取一個圖片作為背景顯示。這里介紹的方法是用ASP+CSS來實現的。

ASP--來自ASP101

以下是引用片段:
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 & objImageFileToUse.Name
Set objImageFileToUse = Nothing

CSS

以下是引用片段:
#pic{
6v電影網[www.aikan.tv/special/6vdianyingwang/]
width: 400px;
height: 300px;
background: url(<%= strImageSrcText %>) no-repeat;
margin: 2em auto;
}

上面代碼要加在header區,不能放在外部CSS文件里。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 昌平区| 五指山市| 繁峙县| 房产| 武乡县| 八宿县| 卢龙县| 通城县| 长治县| 乡宁县| 淅川县| 南川市| 定兴县| 濮阳县| 祁东县| 内乡县| 小金县| 桑日县| 扬中市| 天水市| 镇康县| 瑞金市| 石景山区| 静安区| 平武县| 阳原县| 松阳县| 东山县| 德钦县| 乌拉特中旗| 正安县| 麻城市| 成都市| 泸西县| 德安县| 迭部县| 合江县| 禹城市| 渭源县| 探索| 原平市|