大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> ASP专区 -> ASP/DHTML Image Preloader

ASP/DHTML Image Preloader

时间: 2021-07-31 作者:daque

tutorials & code snips: graphics & charts: images\\this asp script recurses through a directory tree and loads images into a dhtml preloader.first off, big thanks to brian from script asylum for letting me use his dhtml site preloader. this version will be even less work, because all you do is tell the asp to drill down through a directory structure looking for images, and it will place all the image names into an array, and off it goes.the setup for this is incredibly simple. first off, open preloader.asp, and change the following variables:- boolrecurse: tell the script to drill down through subdirectories within the folder you choose (true/false)- strvirtualroot: the folder that contains all the images<%boolrecurse = true ' recurse through subdirectories? true/falsestrvirtualroot = "../../images" ' directorystrrootfolder = server.mappath(strvirtualroot) ' grab the directoryintsize = 0set objfso = server.createobject("scripting.filesystemobject")set objfolder = objfso.getfolder(strrootfolder)stroutput = traversefolder(objfolder, strvirtualroot, boolrecurse)stroutput = mid(stroutput, 1, len(stroutput)-2)set objfso = nothingset objfolder = nothingfunction traversefolder(objfolder, strvirtualroot, boolrecurse) stroutput = ""arrimages = array("gif", "jpg", "png", "jpeg")'only process directories that do not start with'an underscore.if not left(objfolder.name, 1) = "_" thendim objfile, strpath, strfilename, strfilesize, strextension'iterate through each file in the folderfor each objfile in objfolder.files' obtain the extension of the current filestrpath = objfile.pathstrfilename = objfile.nameintfilesize = objfile.sizestrextension = ucase(right(strpath, len(strpath) - instrrev(strpath, ".")))' see if file is an imagefor x = lbound(arrimages) to ubound(arrimages)if strextension = ucase(arrimages(x)) thenstroutput = stroutput & "'" & strvirtualroot & "/" & strfilename & "', "intsize = intsize + intfilesizeend ifnextnextif boolrecurse then'recurse through the folder's subdirectoriesfor each objsubfolder in objfolder.subfoldersstroutput = stroutput & traversefolder(objsubfolder, strvirtualroot & "/" & objsubfolder.name, boolrecurse)nextend iftraversefolder = stroutputend ifend function%>second step is to change the look and feel variables of the site preloader, in progressbar.asp.also be sure to change the action variable, this is a function which will perform an action when all the images are loaded, e.g. go to another page, pop up an alert, etc.<!--#include file="preloader.asp"-->// progressbar - version 2.5// author: brian gosselin of http://scriptasylum.com// put the names of all your images that need to be "cached" in the "imagenames" array.// dont forget the comma between each entry, or the tick marks around each name.// when all the images are done loading, the "imagesdone" variable is set to "true"var imagenames=[<%=stroutput%>];var yposition = 50; // position of load bar from top of window, in pixelsvar loadedcolor = '#aaaaaa' ; // progress bar colorvar unloadedcolor = 'lightgrey'; // bgcolor of unloaded areavar barheight = 20; // height of progress bar in pixels (min 20)var barwidth = 400; // width of the bar in pixels var bordercolor = 'black'; // color of the bordervar intsize = '<%=formatnumber(intsize/1024, 0)%>'; // size in bytes of all the images// the function below contains the action(s) taken once images are done loading.// if no action is desired, take everything out from between the curly braces ({})// but leave the function name and curly braces in place.// presently, it is set to do nothing, but can be changed easily.// to cause a redirect, insert the following line in it: document.location.href="http://redirect_page.html";// update: setcookie() used to "remember" that people have loaded the page, and bypass preloading.var action=function(){setcookie();}click here to test this script (preload.html)download source (preload.zip)external linkshttp://scriptasylum.com

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.