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

用ASP+CSS實現網頁隨機背景

2010-08-28 10:50:01來源:西部e網作者:

    隨機背景--當你每次進入該頁面時,從已指定的圖片文件夾中,隨機選取一個圖片作為背景顯示。這里介紹的方法是用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 & objImageFileToUse.Name
  Set objImageFileToUse = Nothing

  CSS源代碼:

以下是引用片段:
  #pic{
  width: 400px;
  height: 300px;
  background: url() no-repeat;
  margin: 2em auto;
  }

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

關鍵詞:ASP+CSS網頁
主站蜘蛛池模板: 锡林浩特市| 尖扎县| 东城区| 贵溪市| 博爱县| 盐山县| 湖南省| 宁国市| 潜江市| 环江| 蒲江县| 富裕县| 舟山市| 林周县| 茌平县| 彭阳县| 诸暨市| 天津市| 墨竹工卡县| 揭西县| 潼关县| 宁明县| 武夷山市| 勐海县| 海淀区| 高密市| 阿鲁科尔沁旗| 廊坊市| 林西县| 沈丘县| 韶山市| 名山县| 自贡市| 丰都县| 苏尼特右旗| 四平市| 洞口县| 瑞安市| 张家港市| 格尔木市| 开化县|