仓酷云

标题: ASP教程之ASP/DHTML Image Preloader [打印本页]

作者: 简单生活    时间: 2015-1-16 23:19
标题: ASP教程之ASP/DHTML Image Preloader
asp,你就只能等着微软给你解决,它不乐意你就只好悲催。而且asp跑在windows服务器上,windows服务器跟linux比起来简直弱爆了!dhtmlTutorials&CodeSnips:Graphics&Charts:Images


ThisASPScriptrecursesthroughadirectorytreeandloadsimagesintoaDHTMLpreloader.

Firstoff,bigthankstoBrianfromScriptAsylumforlettingmeusehisDHTMLsitepreloader.This
versionwillbeevenlesswork,becauseallyoudoistelltheASPtodrilldownthroughadirectory
structurelookingforimages,anditwillplacealltheimagenamesintoanarray,andoffitgoes.
Thesetupforthisisincrediblysimple.Firstoff,openPreloader.asp,andchangethefollowingvariables:
-boolRecurse:Tellthescripttodrilldownthroughsubdirectorieswithinthefolderyouchoose
(True/False)
-strVirtualRoot:Thefolderthatcontainsalltheimages

<%
boolRecurse=TrueRecursethroughsubdirectories?True/False
strVirtualRoot="../../Images"Directory
strRootFolder=Server.MapPath(strVirtualRoot)Grabthedirectory
intSize=0

SetobjFSO=Server.CreateObject("Scripting.FileSystemObject")
SetobjFolder=objFSO.GetFolder(strRootFolder)

strOutput=TraverseFolder(objFolder,strVirtualRoot,boolRecurse)
strOutput=mid(strOutput,1,Len(strOutput)-2)

SetobjFSO=Nothing
SetobjFolder=Nothing

FunctionTraverseFolder(objFolder,strVirtualRoot,boolRecurse)
strOutput=""

arrImages=Array("gif","jpg","png","jpeg")

OnlyprocessdirectoriesthatdoNOTstartwith
anunderscore.
IfNotLeft(objFolder.Name,1)="_"then
DimobjFile,strPath,strFileName,strFileSize,strExtension

Iteratethrougheachfileinthefolder
ForEachobjFileinobjFolder.Files
Obtaintheextensionofthecurrentfile
strPath=objFile.Path
strFileName=objFile.Name
intFileSize=objFile.Size
strExtension=Ucase(Right(strPath,Len(strPath)-InStrRev(strPath,".")))


Seeiffileisanimage
Forx=LBound(arrImages)toUBound(arrImages)
IfstrExtension=Ucase(arrImages(x))then
strOutput=strOutput&""&strVirtualRoot&"/"&strFileName&","
intSize=intSize+intFileSize
EndIf
Next
Next

IfboolRecursethen
Recursethroughthefolderssubdirectories
ForEachobjSubFolderinobjFolder.SubFolders
strOutput=strOutput&TraverseFolder(objSubFolder,strVirtualRoot&"/"&
objSubFolder.Name,boolRecurse)
Next
EndIf
Traverse</p>想法是和程序员的想法不一样的.至于为什么.大家去想一想.跟心理学有关的
作者: 飘灵儿    时间: 2015-1-20 09:30
Response:从字面上讲是“响应”,因此这个是服务端向客户端发送东西的,例如Response.Write
作者: 小妖女    时间: 2015-1-22 13:11
他的语法和设计思路和VB完全相同,导致很多ASP的书都留一句“相关内容请参考VB的相关教材....”更糟糕的是,相当多的ASP教程混合了Javascript,VBscript等等脚本语言,搞的初学者。
作者: 若天明    时间: 2015-1-29 06:49
Server:这个表示的服务器,操作服务器的一些东西使用这个,如Server.Mappath转换服务器路径,Server.CreateObject实例化一个组件
作者: 变相怪杰    时间: 2015-2-3 21:45
跟学别的语言一样,先掌握变量,流程控制语句(就是ifwhileselect)等,函数/过程,数组
作者: 小女巫    时间: 2015-2-9 05:37
下载一个源代码,然后再下载一个VBScript帮助,在源代码中遇到不认识的函数或是其他什么程序,都可以查帮助进行解决,这样学习效率很高。
作者: 再见西城    时间: 2015-2-27 01:45
代码的可重用性差:由于是面向结构的编程方式,并且混合html,所以可能页面原型修改一点,整个程序都需要修改,更别提代码重用了。
作者: 兰色精灵    时间: 2015-3-8 18:54
它可通过内置的组件实现更强大的功能,如使用A-DO可以轻松地访问数据库。
作者: 金色的骷髅    时间: 2015-3-16 11:51
ASP主要是用好六个对象,其实最主要的是用好其中两个:response和request,就可以随心所欲地控制网页变换和响应用户动作了。
作者: 因胸联盟    时间: 2015-3-22 22:56
最近在学asp,不要问我为什么不直接学.net,因为公司网站是asp做的所以有这个需要,卖了本书asp入门到精通,对里面的六大内置对象老是记不住,还有很多属性和方法看的头晕。




欢迎光临 仓酷云 (http://ckuyun.com/) Powered by Discuz! X3.2