(转)教你制作刷新一次就会变一次的图片
黄靖昀(祛魅)
教你制作刷新一次就会变一次的图片 方案一:使用javascript 首先你必须先申请一个空间,然后建立一个HTML文件(我这里假设你会HTML基础),以下代码是html文件源代码(效果就是你现在看到的我的签名部分) <html> <head> <script LANGUAGE="JavaScript"> bg = new Array(4); <!--这里我只放了4张图片,你要加的话把括号里的4改下就可以.--> bg[0] = './images/0.jpg' <!--单引号里的是图片的地址--> bg[1] = './images/25.jpg' bg[2] = './images/6.jpg' bg[3] = './images/5.jpg' <!--如果你要显示更多的图片这里就必须再加,比如你把上面的new Array(4)改成new Array(7)的话后面就必须补上 bg[4] = '图片地址' bg[5] = '图片地址' bg[6] = '图片地址' 注意:这个bg数组是从0开始到6,一共7个,别搞错了 --> index = Math.floor(Math.random() * bg.length); document.write("<img src="+bg[index]+" width='300' height='300'>"); </script> </head> <body> </body> </html> 将这段代码保存成*.html(比如img.html),并上传到你的空间在发贴的时候加如下代码 <iframe>http://你的空间地址/img.html</iframe> (这里要把尖括号<>改成中括号[],具体可以参看Discuz! 代码使用方法,其他的比如PHPWIND论坛嘛,自己看他们的说明咯) 当然这里的地址要根据你的具体情况自己改了 一切皆有可能 方案二:使用ASP下面给出asp源码 ************************* 随机图片显示 **************************** '使用实例:img.asp?list=图片存放目录 '使用注意:图片目录放于本文件同目录下!需要FSO支持! 说明:只要将变化图片放于一个目录下,修改下面程序的(需要修改的地方)成你的目录名称! 上传本程序和图片文件夹到同一目录下,在发帖时候使用UBB代码形如:即可! '---------------------------------------------------------------------------------------- Function AllPath() Dim Domain,GFilePath Domain = Request.ServerVariables("SERVER_NAME") GFilePath = Request.ServerVariables("PATH_INFO") GFilePath = lcase(left(GFilePath,instrRev(GFilePath,"/"))) ] AllPath = "http://"&Domain&GFilePath x0M3` End Function Function ShowFileList(folderspec) 1w-h KyNt Dim Path,objFSO,objFolder,count,objFile,nume,S Path = Server.MapPath(folderspec) Set objFSO = Server.CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists(Path) Then Set objFolder = objFSO.GetFolder(Path) count = 0 For Each objFile in objFolder.Files count = count+1 Next randomize nume = Int((count*rnd)+1) S = 0 ShowFileList = "" For Each objFile in objFolder.Files S = S + 1 If S = nume Then ShowFileList = objFile.Name Exit For End If Next Set objFolder = Nothing Else ShowFileList = "NO" End If Set objFSO = Nothing End Function Dim list,2004528115924.htm,address,str list = trim(Request.QueryString("list")) if list = "" then Response.write "本页需要正确参数引入,您缺少相关的参数!正确格式如下:"&AllPath&"img.asp?list=(需要修改的地方)" Response.End() end if a 2004528115924.htm = ShowFileList("./"&list&"/") if 2004528115924.htm = "NO" then Response.write "您指定的目录"&list&"不存在,请重新指定!" Response.End() end if if 2004528115924.htm = "" then Response.write "您指定的目录"&list&"没有相关的图片文件存在,请重新指定!" Response.End() end if str = right(2004528115924.htm,3) if str"jpg" and str"gif" then 2004528115924.htm = "erro.gif" end if address = AllPath&list&"/" address = address&2004528115924.htm 来自 http://www.vbyy.com/bbs/read.php?tid-633-keyword-%BD%CC%C4%E3%D6%C6%D7%F7%CB%A2%D0%C2%D2%BB%B4%CE%BE%CD%BB%E1%B1%E4%D2%BB%B4%CE%B5%C4%CD%BC%C6%AC.html
你的回复
回复请先 登录 , 或 注册相关内容推荐
最新讨论 ( 更多 )
- 互联网菩萨 AI 聚合 AICNN 赠送88888永久积分 (黄靖昀)
- 北大研究生杨恒明退学声明 (黄靖昀)
- 通过这个加我,拉群 (黄靖昀)
- 啊,组长完蛋了居然! (竹林七闲)
- 何灿浩:马来西华人谈马来西人华人 (黄靖昀)