gpt4 book ai didi

asp-classic - 如何使用经典ASP从文件夹中显示具有旋转效果的四张图像?

转载 作者:行者123 更新时间:2023-12-04 06:03:54 24 4
gpt4 key购买 nike

我有一个用于存储图像的文件夹,现在我想创建一个幻灯片,例如 here .

我尝试了以下代码(但它在页面刷新时只显示单个图像):

<%@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>

请帮我。

最佳答案

尝试从服务器端实现这一点是非常困难的。您只能分配图像一次,更改它们的唯一方法是让您的用户刷新页面。
您需要做的是使用 JavaScript 在客户端创建幻灯片。幸运的是,有很多库可以帮助您。搜索幻灯片和 jquery,您应该能够找到您需要的内容。 Here's one such link .

关于asp-classic - 如何使用经典ASP从文件夹中显示具有旋转效果的四张图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8602717/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com