Random background-When you go to the page, randomly select a picture from the designated picture folder to display as a background. The method described here is implemented with ASP+CSS.
asp--from ASP101
Const imgs_dir = "/images" Set the address of the picture folder, which randomly displays the Any picture in the folder 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 all 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 Objimage Filetouse = Nothing |
Css
The following is a reference fragment:
} |
The code above should be added to the header area and not be placed in an external CSS file.