Using ASP CSS to implement random background

Source: Internet
Author: User

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 using ASP CSS.

Asp

Here is a quote fragment: Const Imgs_dir = "/images"

' Set the address of the picture folder and randomly display any picture in the folder

The following are the referenced contents:

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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.