У меня есть одна папка, в которой хранятся мои изображения, теперь я хочу создать слайд-шоу, например здесь .
Я попробовал следующий код (но он отображает только одно изображение при обновлении страницы):
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<html>
<head>
<%
Function RandomImage(strPath,strDefault)
On Error Resume Next
'response.Write("HI")
Randomize Timer
' declare all variables
Dim objFSO, objFolder, objFiles, objFile
Dim strFiles, strImages, strPhysical, strFile
' this constant has the names of valid image file name
' extensions and can be modified for more image types
Const strValid = ".gif.jpg.png"
' make sure we have a trailing slash in the path
If Right(strPath,1) <> Chr(47) Then strPath = strPath & Chr(47)
' get the physical path of the folder
strPhysical = Server.MapPath(strPath)
' get a File System Object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' create a folder object
Set objFolder = objFSO.GetFolder(strPhysical)
' get the files collection
Set objFiles = objFolder.Files
' enumerate the files collection looking for images
For Each objFile in objFiles
strFile = LCase(objFile.Name)
If Instr(strValid,Right(strFile,4)) Then
' add vaild images to a string of image names
strFiles = strFiles & strFile & vbTab
End If
Next
' split the image names into an array
strImages = Split(strFiles,vbTab)
' if we have an array...
If UBound(strImages) > 1 Then
' get a random name
RandomImage = strPath & strImages(Int(Rnd(1)*UBound(strImages)))
Else
' otherwise return the default
RandomImage = strDefault
End If
End Function
%>
<%
strImg = RandomImage("./retailers/","./retailers/A1-Supplements.jpg")
strsplit = split(strImg,"/")
' Response.Write(strsplit(2))
' Response.Write("rahul =" &strImg)
' d_desc = Split(Request.Form("strImg"),"/")
' Name of text file to search:
strFileName = "saveimagename.txt"
' Text to search for:
strSearchText = strsplit(2)
'response.Write(strSearchText)&"<br/>"
'response.end()
' Create an instance of the the File System Object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' Open the file
Set objTextFile = objFSO.OpenTextFile(Server.MapPath(strFileName))
URLString = ""
Do While Not objTextFile.AtEndOfStream
strReadLineText = objTextFile.ReadLine
'response.Write(strReadLineText & "<br>")
If strReadLineText<>"" then
If Instr(strReadLineText,",")>0 then
strReadLineTextArr=split(strReadLineText,",")
URLString=strReadLineTextArr(1)
end if
end if
If InStr(lcase(strReadLineText), lcase(strSearchText)) > 0 Then
Exit Do
End If
Loop
strSearchText=""
' Close and release file references
objTextFile.Close
Set objTextFile = Nothing
Set objFSO = Nothing
'Response.Write URLString
'Response.End()
%>
</head>
<body>
<div align="center" style="width:800px; float:left;">
<center>
<table border="0" width="800px">
<tr>
<td>
</td>
<td bgcolor="#000" align="center" style="border:none;">
<a href="<%=URLString%>" target="_blank"><img src="<%=strImg%>" onClick="<%=URLString%>" border="0"></a>
</td>
<td>
</td>
</tr>
</table>
</center>
</div>
</body>
</html>
Пожалуйста, помогите мне.