成人午夜激情影院,小视频免费在线观看,国产精品夜夜嗨,欧美日韩精品一区二区在线播放

用ASP+CSS實現(xiàn)網(wǎng)頁隨機背景

2010-08-28 10:50:01來源:西部e網(wǎng)作者:

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

  ASP源代碼:

以下是引用片段:
  Const IMGS_DIR = "/images"
  '設(shè)定圖片文件夾的地址,隨機顯示該文件夾內(nèi)任一張圖片
  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{
  width: 400px;
  height: 300px;
  background: url() no-repeat;
  margin: 2em auto;
  }

  上面代碼要加在head區(qū),不能放在外部CSS文件里。

關(guān)鍵詞:ASP+CSS網(wǎng)頁
主站蜘蛛池模板: 九龙坡区| 昆明市| 黄浦区| 塔城市| 武义县| 普洱| 永昌县| 甘谷县| 绥德县| 四会市| 淮北市| 浏阳市| 九龙县| 罗田县| 鄄城县| 沁源县| 泽州县| 辽宁省| 任丘市| 浦江县| 日土县| 榕江县| 陇川县| 清苑县| 肥城市| 舒城县| 万盛区| 临安市| 泽州县| 贵溪市| 邓州市| 烟台市| 信阳市| 泰来县| 凉城县| 南澳县| 家居| 新绛县| 涪陵区| 遂溪县| 五莲县|