当前位置: 移动技术网 > IT编程>脚本编程>VBScript > 用vbs模拟的一个asp的分页显示功能

用vbs模拟的一个asp的分页显示功能

2017年12月12日  | 移动技术网IT编程  | 我要评论
刚做完1个项目,闲的无聊,想改改自己homepage,但没有asp权限,所以突发奇想,用vbs模拟了一个图片分页显示功能!由于写的是适合自己使用的功能,难免很多地方不是很完善!也请各位路过的提些意见,若有朋友正好想找类似的功能,或许可以帮助一下,另外,祝论坛的每一位朋友元旦快乐!
复制代码 代码如下:

<script language=vbs>
function showindexpage()
         js=1
         webpath=window.location
         do until left(webpath,1)="#" or js=len(window.location)
                  js=js+1
                  webpath=right(window.location,js)

         loop
         if js=len(window.location) then showindexpage=1 else showindexpage=replace(webpath,"#","")
end function

qz=""              '需要显示的图像文件前缀
hz=".gif"          '需要显示的图像文件后缀
themax=98          '最大显示图像个数
theskip=5          '每行显示多少图像个数
thepage=20         '每页显示多少图像个数

theindex=int(themax/thepage)
if themax mod thepage <> 0 then theindex=theindex+1

for i=1 to theindex
    showindex="<a href=#"&i&" onclick=window.location.reload()>"&"["&i&"]"&"</a> "
    document.write showindex
next
document.write "<br><br><hr>"

if thepage=0 then thepage=themax
for i=1 to thepage
    thenum=i+thepage*(showindexpage()-1)
    if thenum>themax then exit for
    if thenum<10 then
       temp="<img src="&qz&"00"&thenum&hz&"></img>"     
    else if thenum<100 then
            temp="<img src="&qz&"0"&thenum&hz&"></img>"
         else
            temp="<img src="&qz&thenum&hz&"></img>"
         end if
    end if
    document.write temp
    if theskip<>0 then if i mod theskip = 0 then document.write "<br>"
next

document.write "<hr><br><br>"
for i=1 to theindex
    showindex="<a href=#"&i&" onclick=window.location.reload()>"&"["&i&"]"&"</a> "
    document.write showindex
next
</script>


[ctrl+a 全选 注:如需引入外部js需刷新才能执行]

另:
取得#后面的内容可以使用

replace(window.location.hash,"#","")

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网