zoukankan      html  css  js  c++  java
  • js收藏代码

    js收藏代码~


    1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键
        <table border oncontextmenu=return(false)><td>no</table> 可用于Table

      2. <body onselectstart="return false"> 取消选取、防止复制

      3. onpaste="return false" 不准粘贴

      4. oncopy="return false;" oncut="return false;" 防止复制

      5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标

      6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标

      7. <input style="ime-mode:disabled"> 关闭输入法

      8. 永远都会带着框架
      <script language="JavaScript"><!--
      if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
      // -->

      9. 防止被人frame
      <SCRIPT LANGUAGE=JAVASCRIPT><!--
      if (top.location != self.location)top.location=self.location;
      // --></SCRIPT>

      10. 网页将不能被另存为
      <noscript><iframe src=*.html></iframe></noscript>

      11. <input type=button value=查看网页源代码
      onclick="window.location = "view-source:"+ "http://www.webjx.com";">

      12.删除时确认
      <a href="javascript:if(confirm("确实要删除吗?"))location="boos.asp?&areyou=删除&page=1"">删除</a>

      13. 取得控件的绝对位置
      //Javascript
      <script language="Javascript">
      function getIE(e){
      var t=e.offsetTop;
      var l=e.offsetLeft;
      while(e=e.offsetParent){
      t+=e.offsetTop;
      l+=e.offsetLeft;
      }
      alert("top="+t+"/nleft="+l);
      }
      

      //VBScript
      <script language="VBScript"><!--
      function getIE()
      dim t,l,a,b
      set a=document.all.img1
      t=document.all.img1.offsetTop
      l=document.all.img1.offsetLeft
      while a.tagName<>"BODY"
      set a = a.offsetParent
      t=t+a.offsetTop
      l=l+a.offsetLeft
      wend
      msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
      end function
      -->

      14. 光标是停在文本框文字的最后
      <script language="javascript">
      function cc()
      {
      var e = event.srcElement;
      var r =e.createTextRange();
      r.moveStart("character",e.value.length);
      r.collapse(true);
      r.select();
      }
      
      <input type=text name=text1 value="123" onfocus="cc()">

      15. 判断上一页的来源
      javascript:
      document.referrer

      16. 最小化、最大化、关闭窗口
      <object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
      <param name="Command" value="Minimize"></object>
      <object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
      <param name="Command" value="Maximize"></object>
      <OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
      <PARAM NAME="Command" VALUE="Close"></OBJECT>
      <input type=button value=最小化 onclick=hh1.Click()>
      <input type=button value=最大化 onclick=hh2.Click()>
      <input type=button value=关闭 onclick=hh3.Click()>
      本例适用于IE
      

      17.屏蔽功能键Shift,Alt,Ctrl
      
      function look(){
      if(event.shiftKey)
      alert("禁止按Shift键!"); //可以换成ALT CTRL
      }
      document.onkeydown=look;
      

      18. 网页不会被缓存
      <META HTTP-EQUIV="pragma" CONTENT="no-cache">
      <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
      <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
      或者<META HTTP-EQUIV="expires" CONTENT="0">

      19.怎样让表单没有凹凸感?
      <input type=text style="border:1 solid #000000">
      或
      <input type=text style="border-left:none; border-right:none; border-top:none; border-bottom:

      1 solid #000000"></textarea>

      20.<div><span>&<layer>的区别?
      <div>(division)用来定义大段的页面元素,会产生转行
      <span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行
      <layer>是ns的标记,ie不支持,相当于<div>

      21.让弹出窗口总是在最上面:
      <body onblur="this.focus();">

      22.不要滚动条?
      让竖条没有:
      <body style="overflow:scroll;overflow-y:hidden">
      
      让横条没有:
      <body style="overflow:scroll;overflow-x:hidden">
      
      两个都去掉?更简单了
      <body scroll="no">
      

      23.怎样去掉图片链接点击后,图片周围的虚线?
      <a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>

      24.电子邮件处理提交表单
      <form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain">
      <input type=submit>
      </form>

      25.在打开的子窗口刷新父窗口的代码里如何写?
      window.opener.location.reload()

      26.如何设定打开页面的大小
      <body onload="top.resizeTo(300,200);">
      打开页面的位置<body onload="top.moveBy(300,200);">

      27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动
      <STYLE>
      body
      {background-image:url(logo.gif); background-repeat:no-repeat;
      background-position:center;background-attachment: fixed}
      </STYLE>

      28. 检查一段字符串是否全由数字组成
      <script language="Javascript"><!--
      function checkNum(str){return str.match(//D/)==null}
      alert(checkNum("1232142141"))
      alert(checkNum("123214214a1"))
      // -->

      29. 获得一个窗口的大小
      document.body.clientWidth; document.body.clientHeight

      30. 怎么判断是否是字符
      if (/[^/x00-/xff]/g.test(s)) alert("含有汉字");
      else alert("全是字符");

      31.TEXTAREA自适应文字行数的多少
      <textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
      </textarea>
      

      32. 日期减去天数等于第二个日期
      <script language=Javascript>
      function cc(dd,dadd)
      {
      //可以加上错误处理
      var a = new Date(dd)
      a = a.valueOf()
      a = a - dadd * 24 * 60 * 60 * 1000
      a = new Date(a)
      alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日")
      }
      cc("12/23/2002",2)
      

      33. 选择了哪一个Radio
      <HTML><script language="vbscript">
      function checkme()
      for each ob in radio1
      if ob.checked then window.alert ob.value
      next
      end function
      <BODY>
      <INPUT name="radio1" type="radio" value="style" checked>Style
      <INPUT name="radio1" type="radio" value="barcode">Barcode
      <INPUT type="button" value="check" onclick="checkme()">
      </BODY></HTML>

      34.脚本永不出错
      <SCRIPT LANGUAGE="JavaScript">
      <!-- Hide
      function killErrors() {
      return true;
      }
      window.onerror = killErrors;
      // -->
      </SCRIPT>

      35.ENTER键可以让光标移到下一个输入框
      <input onkeydown="if(event.keyCode==13)event.keyCode=9">

      36. 检测某个网站的链接速度:
      把如下代码加入区域中:
      <script language=Javascript>
      tim=1
      setInterval("tim++",100)
      b=1
      var autourl=new Array()
      autourl[1]="www.webjx.net"
      autourl[2]="www.webjx.com"
      autourl[3]="www.sina.com.cn"
      autourl[4]="www.webjx.com"
      autourl[5]="www.cctv.com"
      function butt(){
      document.write("<form name=autof>")
      for(var i=1;i<autourl.length;i++)
      document.write("<input type=text name=txt"+i+" size=10 value=测试中……> =》<input type=text
      name=url"+i+" size=40> =》<input type=button value=GO

      onclick=window.open(this.form.url"+i+".value)><br>")
      document.write("<input type=submit value=刷新></form>")
      }
      butt()
      function auto(url){
      document.forms[0]["url"+b].value=url
      if(tim>200)
      {document.forms[0]["txt"+b].value="链接超时"}
      else
      {document.forms[0]["txt"+b].value="时间"+tim/10+"秒"}
      b++
      }
      function run(){for(var i=1;i<autourl.length;i++)document.write("<img src=http://"+autourl+"/"+Math.random()+" width=1 height=1

      onerror=auto("http://";+autourl+"")>")}
      run()

      37. 各种样式的光标
      auto :标准光标
      default :标准箭头
      hand :手形光标
      wait :等待光标
      text :I形光标
      vertical-text :水平I形光标
      no-drop :不可拖动光标
      not-allowed :无效光标
      help :?帮助光标
      all-scroll :三角方向标
      move :移动标
      crosshair :十字标
      e-resize
      n-resize
      nw-resize
      w-resize
      s-resize
      se-resize
      sw-resize
      

      38.页面进入和退出的特效
      进入页面<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">
      推出页面<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">
      这个是页面被载入和调出时的一些特效。duration表示特效的持续时间,以秒为单位。transition表示使用哪种特效,取值为1-23:
      0 矩形缩小
      1 矩形扩大
      2 圆形缩小
      3 圆形扩大
      4 下到上刷新
      5 上到下刷新
      6 左到右刷新
      7 右到左刷新
      8 竖百叶窗
      9 横百叶窗
      10 错位横百叶窗
      11 错位竖百叶窗
      12 点扩散
      13 左右到中间刷新
      14 中间到左右刷新
      15 中间到上下
      16 上下到中间
      17 右下到左上
      18 右上到左下
      19 左上到右下
      20 左下到右上
      21 横条
      22 竖条
      23 以上22种随机选择一种

      39.在规定时间内跳转
      <META http-equiv=V="REFRESH" content="5;URL=http://www.webjx.com">

      40.网页是否被检索
      <meta name="ROBOTS" content="属性值">
      其中属性值有以下一些:
      属性值为"all": 文件将被检索,且页上链接可被查询;
      属性值为"none": 文件不被检索,而且不查询页上的链接;
      属性值为"index": 文件将被检索;
      属性值为"follow": 查询页上的链接;
      属性值为"noindex": 文件不检索,但可被查询链接;
      属性值为"nofollow": 文件不被检索,但可查询页上的链接。

    40 著字变色文字
    <script>var message="交流论坛"
    var n=0;
    if (document.all){
    document.write('<font size="12px" color="red">')
    for (m=0;m<message.length;m++)
    document.write('<span id="neonlight" style="font-size:12px">'+message.charAt(m)+'</span>')
    document.write('</font>')
    var tempref=document.all.neonlight
    }
    else
    document.write(message)
    function neon(){
    if (n==0){
    for (m=0;m<message.length;m++)
    tempref[m].style.color="#000000"
    }
    tempref[n].style.color="RED"
    if (n<tempref.length-1)
    n++
    else{
    n=0
    clearInterval(flashing)
    setTimeout("beginneon()",500)
    return
    }
    }
    function beginneon(){
    if (document.all)
    flashing=setInterval("neon()",200)
    }
    beginneon()
    </script>
    microci 发表于 >2005-1-5 12:52:13 [全文] [评论] [引用] [推荐] [档案] [推给好友]

    2005-1-5
    最简化分页程序

    pagetest.asp 表现页面

    <!--#include virtual="/conn.asp"-->
    <!--#include virtual="/object.asp"-->
    <%

    strSql = "select * from authors"

    set rs=server.CreateObject("ADODB.RecordSet")

    rs.open strSql,conn,1,1

    set page = new PageBase

    page.pagesize = 3

    if not isnumeric(request("page")) then
    page.currentpage=1
    else
    if (cint(request("page")<1)) then
    page.currentpage=1
    else
    page.currentpage=request("page")
    end if
    end if


    page.linkurl="pagetest.asp"

    page.show(rs)

    page.FenYe(rs)
    %>


    object.asp 页对象

    <%

    '***********************************
    '*
    '* 尼德类
    '*
    '* 主要有:分页类。。。。。
    '*
    '* coolwind QQ :1294420
    '*
    '***********************************

    class PageBase
    dim pagesize '每页显示的记录数
    dim currentpage'当然页面数
    dim linkurl '链结URL

    sub show(oRs)

    '显示分页符号的子程序---------------------------------------------------------------
    i=0
    rs.Move pagesize*(currentpage-1)
    do while not oRs.eof and i<pagesize
    response.write oRs(1)&"<br>"
    i=i+1
    oRs.movenext
    loop
    End sub

    '显示分页符号的子程序---------------------------------------------------------------

    sub FenYe(oRs)

    totalput = oRs.recordcount
    pagesum = totalPut PageSize

    '如果是第一页
    response.write "第"¤tpage&"页/共"&pagesum&"页"

    maxpage = 0
    minpage = 0
    if((currentpage-5)>1) then
    minpage = currentpage-5
    if (currentpage+4)>pagesum then
    maxpage = pagesum
    else
    maxpage = currentpage+4
    end if
    else
    minpage = 1
    if pagesum>10 then
    maxpage = 10
    else
    maxpage = pagesum
    end if
    end if
    if(cint(currentpage-1)>0) then
    if(cint(currentpage-1)>cint(pagesum)) then
    response.write "<a href="&linkurl&"?Page="&pagesum&" ><<上一页</a>"
    else
    response.write "<a href="&linkurl&"?Page="¤tpage-1&" ><<上一页</a>"
    end if
    end if
    for i=minpage to maxpage
    if(cint(i)=cint(currentpage)) then
    response.write "["&i&"]"
    else
    response.write "[<a href="&linkurl&"?Page="&i&" >"&i&"</a>]"
    end if
    next
    if(cint(pagesum-currentpage)>0) then
    response.write "<a href="&linkurl&"?Page="¤tpage+1&">下一页>></a>"
    end if
    response.write "<br>"

    '以下是另一种分页显示界面
    if currentpage=1 then
    Response.Write " [最前页]"
    Response.Write "[上一页]"
    else
    Response.Write "[<a href="&linkurl&"?page=1 class='01'>最前页</a>]"
    Response.Write "[<a href="&linkurl&"?Page="¤tpage-1&" class='01'>上一页</a>]"
    End If

    '如果是最后一页

    If cint(currentpage)<cint(pagesum) Then
    Response.Write "[<A HREF="&linkurl&"?Page="¤tpage+1&" class='01'>下一页</a>]"
    Response.Write "[<A HREF="&linkurl&"?Page="&pagesum&" class='01'>最末页</a>]"
    else
    Response.Write "[下一页]"
    Response.Write "[最末页]"
    End If
    end sub

    end class
    %>


    conn.asp 数据库链结

    <%
    '***********************************
    '*
    '*
    '* 与MSSQL数据库连接
    '*
    '* coolwind QQ :1294420
    '*
    '***********************************
    dim conn
    dim connstr
    connstr="provider=sqloledb;data source=servername;uid=sa;pwd=;database=pubs;"
    set conn=server.createobject("ADODB.CONNECTION")

    if err.number<>0 then
    err.clear
    set conn=nothing
    response.write "数据库连接出错!"
    Response.End
    else
    conn.open connstr
    if err then
    err.clear
    set conn=nothing
    response.write "数据库连接出错!"
    Response.End
    end if
    end if

    %>


    2005-1-5
    JS经典技巧

    1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键
        <table border oncontextmenu=return(false)><td>no</table> 可用于Table

      2. <body onselectstart="return false"> 取消选取、防止复制

      3. onpaste="return false" 不准粘贴

      4. oncopy="return false;" oncut="return false;" 防止复制

      5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标

      6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标

      7. <input style="ime-mode:disabled"> 关闭输入法

      8. 永远都会带着框架
      <script language="JavaScript"><!--
      if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
      // -->

      9. 防止被人frame
      <SCRIPT LANGUAGE=JAVASCRIPT><!--
      if (top.location != self.location)top.location=self.location;
      // --></SCRIPT>

      10. 网页将不能被另存为
      <noscript><iframe src=*.html></iframe></noscript>

      11. <input type=button value=查看网页源代码
      onclick="window.location = "view-source:"+ "http://www.webjx.com";">

      12.删除时确认
      <a href="javascript:if(confirm("确实要删除吗?")location="boos.asp?&areyou=删除&page=1"">删除</a>

      13. 取得控件的绝对位置
      //Javascript
      <script language="Javascript">
      function getIE(e){
      var t=e.offsetTop;
      var l=e.offsetLeft;
      while(e=e.offsetParent){
      t+=e.offsetTop;
      l+=e.offsetLeft;
      }
      alert("top="+t+"/nleft="+l);
      }
      

      //VBScript
      <script language="VBScript"><!--
      function getIE()
      dim t,l,a,b
      set a=document.all.img1
      t=document.all.img1.offsetTop
      l=document.all.img1.offsetLeft
      while a.tagName<>"BODY"
      set a = a.offsetParent
      t=t+a.offsetTop
      l=l+a.offsetLeft
      wend
      msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
      end function
      -->

      14. 光标是停在文本框文字的最后
      <script language="javascript">
      function cc()
      {
      var e = event.srcElement;
      var r =e.createTextRange();
      r.moveStart("character",e.value.length);
      r.collapse(true);
      r.select();
      }
      
      <input type=text name=text1 value="123" onfocus="cc()">

      15. 判断上一页的来源
      javascript:
      document.referrer

      16. 最小化、最大化、关闭窗口
      <object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
      <param name="Command" value="Minimize"></object>
      <object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
      <param name="Command" value="Maximize"></object>
      <OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
      <PARAM NAME="Command" VALUE="Close"></OBJECT>
      <input type=button value=最小化 onclick=hh1.Click()>
      <input type=button value=最大化 onclick=hh2.Click()>
      <input type=button value=关闭 onclick=hh3.Click()>
      本例适用于IE
      

      17.屏蔽功能键Shift,Alt,Ctrl
      
      function look(){
      if(event.shiftKey)
      alert("禁止按Shift键!"; //可以换成ALT CTRL
      }
      document.onkeydown=look;
      

      18. 网页不会被缓存
      <META HTTP-EQUIV="pragma" CONTENT="no-cache">
      <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
      <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
      或者<META HTTP-EQUIV="expires" CONTENT="0">

      19.怎样让表单没有凹凸感?
      <input type=text style="border:1 solid #000000">
      或
      <input type=text style="border-left:none; border-right:none; border-top:none; border-bottom:

      1 solid #000000"></textarea>

      20.<div><span>&<layer>的区别?
      <div>(division)用来定义大段的页面元素,会产生转行
      <span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行
      <layer>是ns的标记,ie不支持,相当于<div>

      21.让弹出窗口总是在最上面:
      <body onblur="this.focus();">

      22.不要滚动条?
      让竖条没有:
      <body style="overflow:scroll;overflow-y:hidden">
      
      让横条没有:
      <body style="overflow:scroll;overflow-x:hidden">
      
      两个都去掉?更简单了
      <body scroll="no">
      

      23.怎样去掉图片链接点击后,图片周围的虚线?
      <a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>

      24.电子邮件处理提交表单
      <form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain">
      <input type=submit>
      </form>

      25.在打开的子窗口刷新父窗口的代码里如何写?
      window.opener.location.reload()

      26.如何设定打开页面的大小
      <body onload="top.resizeTo(300,200);">
      打开页面的位置<body onload="top.moveBy(300,200);">

      27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动
      <STYLE>
      body
      {background-image:url(logo.gif); background-repeat:no-repeat;
      background-position:center;background-attachment: fixed}
      </STYLE>

      28. 检查一段字符串是否全由数字组成
      <script language="Javascript"><!--
      function checkNum(str){return str.match(//D/)==null}
      alert(checkNum("1232142141")
      alert(checkNum("123214214a1")
      // -->

      29. 获得一个窗口的大小
      document.body.clientWidth; document.body.clientHeight

      30. 怎么判断是否是字符
      if (/[^/x00-/xff]/g.test(s)) alert("含有汉字";
      else alert("全是字符";

      31.TEXTAREA自适应文字行数的多少
      <textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
      </textarea>
      

      32. 日期减去天数等于第二个日期
      <script language=Javascript>
      function cc(dd,dadd)
      {
      //可以加上错误处理
      var a = new Date(dd)
      a = a.valueOf()
      a = a - dadd * 24 * 60 * 60 * 1000
      a = new Date(a)
      alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日"
      }
      cc("12/23/2002",2)
      

      33. 选择了哪一个Radio
      <HTML><script language="vbscript">
      function checkme()
      for each ob in radio1
      if ob.checked then window.alert ob.value
      next
      end function
      <BODY>
      <INPUT name="radio1" type="radio" value="style" checked>Style
      <INPUT name="radio1" type="radio" value="barcode">Barcode
      <INPUT type="button" value="check" onclick="checkme()">
      </BODY></HTML>

      34.脚本永不出错
      <SCRIPT LANGUAGE="JavaScript">
      <!-- Hide
      function killErrors() {
      return true;
      }
      window.onerror = killErrors;
      // -->
      </SCRIPT>

      35.ENTER键可以让光标移到下一个输入框
      <input onkeydown="if(event.keyCode==13)event.keyCode=9">

      36. 检测某个网站的链接速度:
      把如下代码加入区域中:
      <script language=Javascript>
      tim=1
      setInterval("tim++",100)
      b=1
      var autourl=new Array()
      autourl[1]="www.webjx.net"
      autourl[2]="www.webjx.com"
      autourl[3]="www.sina.com.cn"
      autourl[4]="www.webjx.com"
      autourl[5]="www.cctv.com"
      function butt(){
      document.write("<form name=autof>"
      for(var i=1;i<autourl.length;i++)
      document.write("<input type=text name=txt"+i+" size=10 value=测试中……> =》<input type=text
      name=url"+i+" size=40> =》<input type=button value=GO

      onclick=window.open(this.form.url"+i+".value)><br>"
      document.write("<input type=submit value=刷新></form>"
      }
      butt()
      function auto(url){
      document.forms[0]["url"+b].value=url
      if(tim>200)
      {document.forms[0]["txt"+b].value="链接超时"}
      else
      {document.forms[0]["txt"+b].value="时间"+tim/10+"秒"}
      b++
      }
      function run(){for(var i=1;i<autourl.length;i++)document.write("<img src=http://"+autourl+"/"+Math.random()+" width=1 height=1

      onerror=auto("http://";+autourl+"" >"}
      run()

      37. 各种样式的光标
      auto :标准光标
      default :标准箭头
      hand :手形光标
      wait :等待光标
      text :I形光标
      vertical-text :水平I形光标
      no-drop :不可拖动光标
      not-allowed :无效光标
      help :?帮助光标
      all-scroll :三角方向标
      move :移动标
      crosshair :十字标
      e-resize
      n-resize
      nw-resize
      w-resize
      s-resize
      se-resize
      sw-resize
      

      38.页面进入和退出的特效
      进入页面<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">
      推出页面<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">
      这个是页面被载入和调出时的一些特效。duration表示特效的持续时间,以秒为单位。transition表示使用哪种特效,取值为1-23:
      0 矩形缩小
      1 矩形扩大
      2 圆形缩小
      3 圆形扩大
      4 下到上刷新
      5 上到下刷新
      6 左到右刷新
      7 右到左刷新
      8 竖百叶窗
      9 横百叶窗
      10 错位横百叶窗
      11 错位竖百叶窗
      12 点扩散
      13 左右到中间刷新
      14 中间到左右刷新
      15 中间到上下
      16 上下到中间
      17 右下到左上
      18 右上到左下
      19 左上到右下
      20 左下到右上
      21 横条
      22 竖条
      23 以上22种随机选择一种

      39.在规定时间内跳转
      <META http-equiv=V="REFRESH" content="5;URL=http://www.webjx.com">

      40.网页是否被检索
      <meta name="ROBOTS" content="属性值">
      其中属性值有以下一些:
      属性值为"all": 文件将被检索,且页上链接可被查询;
      属性值为"none": 文件不被检索,而且不查询页上的链接;
      属性值为"index": 文件将被检索;
      属性值为"follow": 查询页上的链接;
      属性值为"noindex": 文件不检索,但可被查询链接;
      属性值为"nofollow": 文件不被检索,但可查询页上的链接。


    microci 发表于 >2005-1-5 12:41:54 [全文] [评论] [引用] [推荐] [档案] [推给好友]

    2004-11-17
    ASP.Net的Cookie实现

    ASP.Net的Cookie实现


    Cookie的用法也和ASP中差不多。比如我们建立一个名为aspcn,值为飞刀的cookie
    HttpCookie cookie = new HttpCookie["aspcn"];
    cookie.Value = "飞刀";
    Response.AppendCookie(cookie);

    我们取出Cookie值也很简单
    HttpCookie cookie = Request.Cookies["aspcn"];
    cookieValue = cookie.Value;

    有时候我们想在一个Cookie中储存多个信息,那也没有问题。比如我们在名为aspcn的cookie下加多个信息
    HttpCookie cookie = new HttpCookie("aspcn";
    cookie.Values.Add("webmaster","飞刀";
    cookie.Values.Add("writer","beige";
    cookie.Values.Add("LinkColor","blue";
    Response.AppendCookie(cookie);

    取出信息也一样简单
    HttpCookie cookie = Request.Cookies["aspcn"];
    value1 = cookies.Values["webmaster"];
    value2 = cookies.Values["writer"];


    View State
    这是一个新出来的东东,用法和Session一样,他的主要用途是记录Web Control的状态。虽然是新出来的,但是和Application、Session的用法没有什么区别,所以也不想详细讲解了。
    State["DropLoadIndex"] = 0 ;
    基本用法如上:),但是请记住,他保存在的信息只能在一个aspx文件中使用。出去后,这个就没有用了,因为他的用途只是保存WEB控件的状态。


    microci 发表于 >2004-11-17 22:53:03 [全文] [评论] [引用] [推荐] [档案] [推给好友]

    2004-11-17
    6个ASP基础问题

    A:1.如何判断用户输入的是一串空格?空格的长度不确定。

    2.如何使某一个页面停留一会儿,自动转到另一个页面?

    3.如何用不同的按钮将<FORM>和</form>之间的控件的信息传递到不同的页面?

    4.如何弹出一个新窗口来显示一个新的页面,但不要弹出确认窗口之类的对话框?

    5.如何在删除(或修改)数据前弹出一个对话框,用于用户是否确认,当用户点"确认"按钮时,执行删除动作,当点"取消"按钮时则不做任何动作?

    6.当程序执行到response.redirect"abc.asp"语句时,在该语句后面的语句是否会被执行?

    Q1:
    1. Trim("Text" = ""
    2. <meta content=100;url=main.asp http-equiv=refresh>
    3.
    function send1()
    {
    document.form_query.action="a.asp";
    document.form_query.submit();
    }
    function send2()
    {
    document.form_query.action="b.asp";
    document.form_query.submit();
    }
    不同的按钮触发不同的事件
    4.不太明白你的意思,但给你一个打开窗口的函数
    function openwindow(url, winName, width, height)
    {
    xposition = (screen.width - width) / 2;
    yposition = (screen.height - height) / 2 - 50;
    theproperty = "width=" + width + "," + "height=" + height + "," + "location=0," + "menubar=0," + "resizable=1," + "scrollbars=1," + "status=0," + "titlebar=0," + "toolbar=0," + "hotkeys=0," + "left=" + xposition + "," + "top=" + yposition;
    window.open(url,winName,theproperty ;
    }
    5.
    <input type='button' value=' 删除 ' name='Bt_Del' onclick="javascript:if(confirm('删除?')===true) Fmdelete(); else return false;">
    6.不会

    Q2:
    1.if trim(request("inputName")='' then

    2.<script language="javascript">setTimeout('nextUrl.asp',1000);//1000为一秒

    3.<script language="javascript">
    function goSend(v)
    {if (1==v) {document.form1.action='save1.asp'; document.form1.submit();}
    if (2==v) {document.form1.action='save2.asp'; document.form1.submit();}
    if (3==v) {document.form1.action='save3.asp'; document.form1.submit();}
    }

    <form name=form1 ><input type="submit" value="1" onclick="goSend(1)">
    <input type="submit" value="1" onclick="goSend(2)">
    <input type="submit" value="1" onclick="goSend(3)">
    </form>

    4<script language="javascript">
    window.open(url,name);

    5.....

    microci 发表于 >2004-11-17 15:09:04 [全文] [评论] [引用] [推荐] [档案] [推给好友]

    2004-11-17
    Flash中使用ASP需要的条件

    在Flash中使用ASP需要的条件:
    1。你的ISP的server必须支持Active Server Pages并且最好支持数据库
    2。你应该要安装Flash 4
    3。需要你对ASP有初步的了解
    OK,下面具体介绍怎么使用:数据库结构:第一步要做的是建立数据库.例子中使用Access数据库,表名为tblStaff
    有三个字段:strID (自动编号), strKnownAs(Text),strSurname (Text).
    这是一个用来示范用户名的数据库,随便加些数据把.第二步就是建立一个Flash 4的动画罗:步骤如下:
    1)建立三个text field.它们是用来显示数据用的 2)把第一个text field的name设置为Input,它是用来接收输入数据的
    3)另外两个text field分别命名为KnownAs和Surname 4)其它设置先为默认
    5)最后,从Flash的library中选择增加一个按钮 (应该是一个可重用的组件ScrollBarButton .
    这是很重要的一步,按钮将把输入的变量传递给ASP页面
    到按钮的属性(Properties)上单击Action页. 单击"+"号和On MouseEvent.勾上Release框.
    6)再次单击"+"号和Load/Unload Movie.选择"Load Variables Into Location"
    在URL输入框内输入你的ASP文件名(例如flash.asp). 选择Target.
    7)最后,选择Variables中的Send using POST. 单击"+"号来设置变量
    在Variable输入框内输入"Input"(就是第一个text field的name)
    当上面的工作都完成后,你应该在action box内看到如下内容:
    On (Release)
    Load Variables
    ("flash.asp", "", vars=POST)
    Set Variable: "Input" = ""
    End On
    这样当在动画过程中这个按钮被点击并释放后,Input输入框中的内容将被传递给flash.asp文件. 注意form是使用的post方式传递变量的.
    8)现在建立一个HTML页面,在其中包含这个Flash动画文件第三步:ASP文件的代码 <%
    Set Connection = Server.CreateObject
    ("ADODB.Connection"
    Set Recordset = Server.CreateObject
    ("ADODB.Recordset"
    Connection.Open "people" '你的数据库连接的DSN
    SQL = "SELECT * FROM tblStaff WHERE
    strID=" & Request.Form("Input" & ";"
    Recordset.Open SQL,Connection,1,2
    If Recordset.EOF Then
    KnownAs = "Not"
    Surname = "Found"
    Else
    KnownAs = Recordset ("strKnownAs"
    Surname = Recordset ("strSurname"
    End If
    Recordset.Close
    Connection.Close
    response.write
    ("KnownAs="+Server.URLEncode(KnownAs))
    response.write
    ("&Surname="+Server.URLEncode(Surname)) %>
    需要注意的是在把KnownAs和Surname传递回去的写法,将是这样的
    KnownAs=Data1&Surname=Data2
    使用Server.URLEncode(VariableName)来保证传递过去变量的是按照 URL格式编码的
    下面简单介绍一下ASP和Flash通讯的原理: 变量其实都是通过URL传递给Flash的,其实这是一种GET方法
    你不使用ASP其实也可以把变量传递给一个swf文件的,只要这样:
    <PARAM NAME=movie VALUE="myMovie.swf?
    myVariable=Text+of+my+variable">
    接着文本"Text of my variable"将会出现在Flash的动画中指定的位置
    好了,该说的都说了,现在对于ASP的开发者来说,只要把Flash所需要的数据准备好,然后利用Flash中的动画
    功能就可以做出强劲的网页出来了.最简单的是利用flash结合数据库画一个很漂亮的饼图,呵呵.反正只要大家能够想象就可以做出很多很好的东西出来的.


    microci 发表于 >2004-11-17 15:03:32 [全文] [评论] [引用] [推荐] [档案] [推给好友]

    2004-11-17
    ASP通用分页类 v2.8 二


    '*****************************************
    ' 类型: 属性
    ' 目的: 设置显示标题时单元格的宽度
    ' 输入: a_strTleWidth:单元格宽度字符串
    ' 返回: 无
    '*****************************************
    Public Property Let TleWidth(a_strWidth)
    SW_strTleWidth = a_strWidth
    End Property

    '*****************************************
    ' 类型: 属性
    ' 目的: 设置显示标题时单元格分隔线的类型
    ' 输入: a_intBDType 单元格分隔线的类型
    ' 返回: 无
    '*****************************************
    Public Property Let TleBDType(a_intBDType)
    SW_intTleBDType = a_intBDType
    End Property

    '*****************************************
    ' 类型: 过程
    ' 目的: 统计总记录数、计算总页数
    ' 输入: 无
    ' 返回: 无
    '*****************************************
    Sub Init()
    Dim intPostion,strError,i,objRSTemp,lngTotalRecord

    If Not (SW_blnConn and SW_blnOpenRS and SW_blnPageSize and SW_blnGetURL) Then
    Call ShowErrors()
    Exit Sub
    End If

    If SW_objRS.Eof And SW_objRS.Bof Then
    strError = strError & "<br>库中无任何记录"
    End If

    '计算总计录数
    Set objRSTemp = SW_objConn.Execute("SELECT * FROM SW_RecCount"
    lngTotalRecord = CLng(objRSTemp("SW_RecCount".Value)
    SW_lngTotalRecord = lngTotalRecord
    If (SW_lngTotalRecord<=2147483647 AND SW_lngTotalRecord>=-2147483648) Then
    SW_lngTotalRecord = CLng(SW_lngTotalRecord)
    Else
    strError = strError & "<br>分页初始化时:总记录数溢出"
    End If
    If SW_lngTotalRecord <=0 Then strError = strError & "<br>分页初始化时:总记录数小于零"

    '计算总页数
    If SW_lngTotalRecord Mod SW_intPageSize = 0 Then
    SW_lngTotalPage = CLng(SW_lngTotalRecord SW_intPageSize * -1)*-1
    Else
    SW_lngTotalPage = CLng(SW_lngTotalRecord SW_intPageSize * -1)*-1 + 1
    End If

    '获取页数
    SW_lngPageNo = Trim(Request.QueryString("pageno")
    If SW_lngPageNo = "" Then SW_lngPageNo = Trim(Request.Form("PageNo")
    If SW_lngPageNo = "" Then SW_lngPageNo = 1
    '如果没有选择第几页,则默认显示第一页
    If SW_lngPageNo <> "" And IsNumeric(SW_lngPageNo) Then
    If (SW_lngPageNo <= 2147483647 And SW_lngPageNo>=-2147483648) Then
    SW_lngPageNo = CLng(SW_lngPageNo)
    Else
    strError = strError & "<br>页数溢出,请检查!"
    End If
    If (SW_lngPageNo<=0) Then strError = strError & "<br>页数只能是正整数!"
    Else
    strError = strError & "<br>你确信此页数 <font color=""#FF0000"">" & SW_lngPageNo & "</font> 存在?"
    End If

    If (SW_lngPageNo > SW_lngTotalPage AND SW_lngTotalPage<>0) Then SW_lngPageNo = SW_lngTotalPage

    SW_objRS.PageSize = SW_intPageSize
    SW_objRS.AbsolutePage = SW_lngPageNo

    intPostion = InstrRev(SW_strURL,"?"
    SW_strFormAction = SW_strURL
    If intPostion > 0 Then
    SW_strURL = SW_strURL & "&PageNo="
    Else
    SW_strURL = SW_strURL & "?PageNo="
    End If

    If Trim(SW_strFields) = "" Then
    For i = 0 To SW_objRS.Fields.Count-1
    SW_strFields = SW_strFields & SW_objRS(i).Name & ","
    Next
    End If

    SW_strFields = LCase("," & Trim(SW_strFields))
    If IsArray(SW_aryFldName) Then
    For i = LBound(SW_aryFldName) To Ubound(SW_aryFldName)
    If Instr(SW_strFields,"," & SW_aryFldName(i) & "," = 0 Then strError = strError & "<br>字段名 <font color=""#ff0000"">" & SW_aryFldName(i) & "</font> 正确吗?"
    Next

    If (IsArray(SW_aryFldNote) AND UBound(SW_aryFldName)>UBound(SW_aryFldNote)) Then strError = strError & "<br>字段相应中文说明项目不能小于字段个数"

    If (IsArray(SW_aryFldWidth) AND UBound(SW_aryFldName)>UBound(SW_aryFldWidth)) Then strError = strError & "<br>字段相应宽度项目不能小于字段个数"

    If (IsArray(SW_aryFldAlign) AND UBound(SW_aryFldName)>UBound(SW_aryFldAlign)) Then strError = strError & "<br>字段数据相应对齐方式项目不能小于字段个数"
    If (IsArray(SW_aryFldLink) AND UBound(SW_aryFldName)>UBound(SW_aryFldLink)) Then strError = strError & "<br>字段数据相应文件链接项目不能小于字段个数"
    End If

    If Trim(strError) = "" Then
    SW_blnInit = true
    Else
    SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">Init过程:</font></td></tr>" & vbcrlf
    SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf
    End If
    Response.Write(SW_strHeadJS & vbcrlf)
    End Sub

    '*****************************************
    ' 类型: 过程
    ' 目的: 显示分页信息
    ' 输入: 无
    ' 返回: 无
    '*****************************************
    Private Sub Pages()
    Dim strPages,k,intTemp,intTemp1

    If Not(SW_blnInit) Then Call ShowErrors()

    If SW_lngTotalPage = 1 Then Exit Sub
    Response.Write("<table align=""center"" class=""css_ShowPage"" width=""" & SW_strShowWidth & """>" & vbcrlf)

    Response.Write(" <tr>" & vbcrlf)
    Response.Write(" <td>" & vbcrlf)
    Response.Write(" <table width=""100%"">" & vbcrlf)
    Response.Write(" <tr>" & vbcrlf & " <td align=""center"" valign=""middle"" class="".test1"">" & vbcrlf)

    If SW_lngTotalPage >= 1 Then
    SELECT CASE SW_intShowPageType
    Case SW_intShowChinese
    If SW_lngPageNo <= 1 Then
    Response.Write ("<font color=""" & SW_strFTColor & """>首页 前页 <a href=""" & SW_strURL & SW_lngPageNo+1 & """>后页</a> <a href=""" & SW_strURL & SW_lngTotalPage & """>末页</a>" & vbcrlf)
    Else
    If SW_lngPageNo >= SW_lngTotalPage Then
    Response.Write ("<font color=""" & SW_strFTColor & """><a href=""" & SW_strURL & "1"">首页</a> <a href=""" & SW_strURL & SW_lngPageNo -1 & """>前页</a> " & "后页 末页" & vbcrlf)
    Else
    Response.Write ("<font color=""" & SW_strFTColor & """><a href=""" & SW_strURL & "1"">首页</a> <a href=""" & SW_strURL & SW_lngPageNo -1 & """>前页</a> " & "<a href=""" & SW_strURL & SW_lngPageNo+1 & """>后页</a> <a href=""" & SW_strURL & SW_lngTotalPage & """>末页</a>" & vbcrlf)
    End If
    End If
    Response.Write (" 页次:<b>" & SW_lngPageNo & "</b>/" & SW_lngTotalPage & "页 共<b>" & SW_lngTotalRecord & "</b>条记录 <b>" & SW_intPageSize & "</b>条/页</td>" & vbcrlf)
    Response.Write(" <form name=""gopage"" action=""" & SW_strFormAction & """ method=""post"">" & vbcrlf)
    Response.Write(" <td> 第"
    Response.Write(" <input type=""text"" name=""pageno"" size=""3"" maxlength=4 title=""请输入页号,然后回车"">页 " & vbcrlf)
    Response.Write("<input type=""submit"" value=""GO""></td></form></tr>" & vbcrlf)
    Case SW_intShowEnglish
    If SW_lngPageNo <= 1 Then
    Response.Write ("<font color=""" & SW_strFTColor & """>First Prev <a href=""" & SW_strURL & SW_lngPageNo+1 & """>Next</a> <a href=""" & SW_strURL & SW_lngTotalPage & """>Last</a>" & vbcrlf)
    Else
    If SW_lngPageNo >= SW_lngTotalPage Then
    Response.Write ("<font color=""" & SW_strFTColor & """><a href=""" & SW_strURL & "1"">First</a> <a href=""" & SW_strURL & SW_lngPageNo -1 & """>Prev</a> " & "Next Last" & vbcrlf)
    Else
    Response.Write ("<font color=""" & SW_strFTColor & """><a href=""" & SW_strURL & "1"">First</a> <a href=""" & SW_strURL & SW_lngPageNo -1 & """>Prev</a> " & "<a href=""" & SW_strURL & SW_lngPageNo+1 & """>Next</a> <a href=""" & SW_strURL & SW_lngTotalPage & """>Last</a>" & vbcrlf)
    End If
    End If
    Response.Write (" Page No:<b>" & SW_lngPageNo & "</b>/" & SW_lngTotalPage & " Total Records:<b>" & SW_lngTotalRecord & "</b> PageSize:<b>" & SW_intPageSize & "</b></td>" & vbcrlf)
    Response.Write(" <form name=""gopage"" action=""" & SW_strFormAction & """ method=""post"">" & vbcrlf)
    Response.Write(" <td> "
    Response.Write(" <input type=""text"" name=""pageno"" size=""3"" maxlength=4 title=""Please input pageno then enter""> " & vbcrlf)
    Response.Write("<input type=""submit"" value=""GO""></td></form></tr>" & vbcrlf)
    Case SW_intShowCharacter
    strPages = ""
    intTemp = (SW_lngPageNo SW_intShowPages) * SW_intShowPages
    If SW_lngPageNo Mod SW_intShowPages = 0 Then intTemp = intTemp - 10
    For k = 1 To SW_intShowPages
    intTemp1 = intTemp + k

    If intTemp1 > SW_lngTotalPage Then Exit For
    If SW_lngPageNo = intTemp1 Then
    If Len(Trim(CStr(intTemp1)))<2 Then
    strPages = strPages & " 0" & CStr(intTemp1)
    Else
    strPages = strPages & " " & CStr(intTemp1)
    End If
    Else
    strPages = strPages & " <a href=""" & SW_strURL & CStr(intTemp1) & """>"
    If Len(Trim(CStr(intTemp1)))<2 Then
    strPages = strPages & "0" & CStr(intTemp1)
    Else
    strPages = strPages & CStr(intTemp1)
    End If
    strPages = strPages & "</a>"
    End If
    Next
    If SW_lngPageNo <= 1 Then
    Response.Write ("<font face=""Webdings"">9 7</font>" & strPages & " <a href=""" & SW_strURL & SW_lngPageNo+1 & """><font face=""Webdings"">8</font></a> <a href=""" & SW_strURL & SW_lngTotalPage & """><font face=""Webdings"">:</font></a>" & vbcrlf)
    Else
    If SW_lngPageNo >= SW_lngTotalPage Then
    Response.Write ("<a href=""" & SW_strURL & "1""><font face=""Webdings"">9</font></a> <a href=""" & SW_strURL & SW_lngPageNo -1 & """><font face=""Webdings"">7</font></a>" & strPages & " <font face=""Webdings"">8 :</font>" & vbcrlf)
    Else
    Response.Write ("<a href=""" & SW_strURL & "1""><font face=""Webdings"">9</font></a> <a href=""" & SW_strURL & SW_lngPageNo -1 & """><font face=""Webdings"">7</font></a> " & strPages & " <a href=""" & SW_strURL & SW_lngPageNo+1 & """><font face=""Webdings"">8</font></a> <a href=""" & SW_strURL & SW_lngTotalPage & """><font face=""Webdings"">:</font></a>" & vbcrlf)
    End If
    End If

    Response.Write ("</td>" & vbcrlf)
    Response.Write(" <form name=""gopage"" action=""" & SW_strFormAction & """ method=""post"">" & vbcrlf)
    Response.Write(" <td> "
    Response.Write(" <input type=""text"" name=""pageno"" size=""3"" maxlength=10 title=""Please input pageno then enter""> " & vbcrlf)
    Response.Write("<input type=""submit"" value=""GO""></td></form></tr>" & vbcrlf)
    ' Case SW_intShowImage
    Case Else
    Response.Write("<br>对不起,你设置的显示方式SWPage不支持。"
    Response.End
    End Select
    End If
    Response.Write(" </table>" & vbcrlf)
    Response.Write(" </td>" & vbcrlf)
    Response.Write(" </tr>" & vbcrlf)
    Response.Write("</table>" & vbcrlf)
    End Sub

    '*****************************************
    ' 类型: 过程
    ' 目的: 显示分页数据
    ' 输入: 无
    ' 返回: 无
    '*****************************************
    Sub Show()
    Dim i,j

    If Not(SW_blnInit) Then Call ShowError()

    j = 0
    If SW_objRS.Eof And SW_objRS.Bof Then
    Response.Write("库中无任何记录<br>"
    Response.End
    Else
    If SW_intShowPagePos = SW_intPageInAll Or SW_intShowPagePos = SW_intPageInTop Then Call Pages()

    '空行
    Response.Write("<table><tr><td height=""5""></td></tr></table>" & vbcrlf)

    SELECT CASE SW_intShowType
    Case SW_intHorizontalView '横排
    Do While (Not SW_objRS.Eof AND j<SW_intPageSize)
    Response.Write(" <table class=""css_showdata_tb"" width=""" & SW_strShowWidth & """ align=""center"">" & vbcrlf)
    For i = LBound(SW_aryFldName) To UBound(SW_aryFldName)
    Response.Write(" <tr class=""css_showdata_title_H"" height=""28"">" & vbcrlf)
    Response.Write(" <td class=""css_showdata_V"" align=""center"" width=""" & SW_strTleWidth & """>" & vbcrlf & "&nbsp;"
    If (IsArray(SW_aryFldNote)) Then
    Response.Write(SW_aryFldNote(i) & vbcrlf)
    Else
    Response.Write(SW_aryFldName(i) & vbcrlf)
    End If

    Response.Write(" </td>" & vbcrlf & " <td class=""css_showdata_td"" "

    If (IsArray(SW_aryFldWidth)) Then Response.Write(" width=""" & SW_aryFldWidth(i) & """"

    If (IsArray(SW_aryFldAlign)) Then Response.Write(" align=""" & SW_aryFldAlign(i) & """"

    Response.Write(">" & vbcrlf)

    If (IsArray(SW_aryFldLink) AND (Trim(SW_aryFldLink(i))<>"") Then
    Response.Write("<a href=""" & SW_aryFldLink(i) & """ target=""_blank"">" & SW_objRS(SW_aryFldName(i)) & "</a></td>" & vbcrlf)
    Else
    Response.Write(SW_objRS(SW_aryFldName(i)) & "</td>" & vbcrlf)
    End If

    Response.Write(" </tr>" & vbcrlf)
    Next
    Response.Write(" </table>" & vbcrlf)
    '空行
    Response.Write("<table><tr><td height=""5""></td></tr></table>" & vbcrlf)
    SW_objRS.MoveNext
    j = j + 1
    Loop
    CASE SW_intVerticalView '竖排
    If SW_intTleBDType = SW_intTleNoBorder Then
    Response.Write(" <table class=""css_showdata_tb"" align=""center"" width=""" & SW_strShowWidth & """>" & vbcrlf)
    Response.Write(" <tr class=""css_title""><td colspan=""" & CStr(UBound(SW_aryFldName)+1) & """>" & vbcrlf)
    Response.Write(" <table border=""0"" width=""100%""><tr>"
    For i = LBound(SW_aryFldName) To UBound(SW_aryFldName)
    Response.Write(" <td align=""center"""
    If (IsArray(SW_aryFldWidth)) Then Response.Write(" width=""" & SW_aryFldWidth(i) & """>"
    If (IsArray(SW_aryFldNote)) Then
    Response.Write(SW_aryFldNote(i) & vbcrlf)
    Else
    Response.Write(SW_aryFldName(i) & vbcrlf)
    End If
    Response.Write(" </td>" & vbcrlf)
    Next
    Response.Write(" </tr></table></td></tr>" & vbcrlf)
    Else
    Response.Write(" <table class=""css_showdata_tb"" width=""" & SW_strShowWidth & """ align=""center"">" & vbcrlf)
    Response.Write(" <tr class=""css_Title"" height=""28"">" & vbcrlf)
    For i = LBound(SW_aryFldName) To UBound(SW_aryFldName)
    Response.Write(" <td class=""css_showdata_td"" align=""center"""
    If (IsArray(SW_aryFldWidth)) Then Response.Write(" width=""" & SW_aryFldWidth(i) & """>"
    If (IsArray(SW_aryFldNote)) Then
    Response.Write(SW_aryFldNote(i))
    Else
    Response.Write(SW_aryFldName(i))
    End If
    Response.Write(" </td>" & vbcrlf)
    Next
    Response.Write(" </tr>" & vbcrlf)
    End If

    Do While (Not SW_objRS.Eof AND j<SW_intPageSize)
    Response.Write(" <tr class=""CSS_ShowData_tr"" height=""28"">" & vbcrlf)
    For i = LBound(SW_aryFldName) To UBound(SW_aryFldName)
    Response.Write( "<td class=""css_showdata_td"""
    If (IsArray(SW_aryFldAlign)) Then Response.Write(" align=""" & SW_aryFldAlign(i) & """ width=""" & SW_aryFldWidth(i) & """>"
    If (IsArray(SW_aryFldLink) AND Trim(SW_aryFldLink(i)<>"") Then
    Response.Write(" <a href=""" & SW_aryFldLink(i) & """ target=""_blnak"">" & SW_objRS(SW_aryFldName(i)) & "</a></td>"
    Else
    Response.Write(SW_objRS(SW_aryFldName(i)) & " </td>" & vbcrlf)
    End If
    Next

    Response.Write(" </tr>" & vbcrlf)
    SW_objRS.MoveNext
    j = j + 1
    Loop
    Response.Write(" </table>" & vbcrlf)
    Response.Write("<table><tr><td height=""5""></td></tr></table>" & vbcrlf)
    CASE ELSE
    Response.Write("<br>你还没设置数据的显示方式?或者你的设置的显示方式SWPage不支持!<br>"
    Response.End
    End SELECT
    If SW_intShowPagePos = SW_intPageInAll Or SW_intShowPagePos = SW_intPageInBottom Then Call Pages()
    Response.Write( SW_strFootJS & vbcrlf)
    End If
    End Sub

    '*****************************************
    ' 类型: 过程
    ' 目的: 显示分页类中出现的错误信息
    ' 输入: 无
    ' 返回: 无
    '*****************************************
    Private Sub ShowErrors()
    If SW_strError <> "" Then
    SW_strError = "<table bgcolor=""#0000"" cellspacing=""1"" cellpadding=""0"" width=""90%"" align=""center"">" & vbcrlf & " <tr bgcolor=""#ff9900"" height=""30""><td align=""center"" valign=""middle""><b>SWPage分页类错误信息<b></td></tr>" & vbcrlf & SW_strError & "</table>" & vbcrlf
    Response.Write(SW_strError)
    Response.End
    End If
    End Sub

    '*****************************************
    ' 类型: 过程
    ' 目的: 释放资源
    ' 输入: 无
    ' 返回: 无
    '*****************************************
    Sub Close()
    Set SW_objRS = Nothing
    Set SW_objConn = Nothing
    End Sub
    End Class
    %>

    三、类的应用代码

    <%Option Explicit
    Dim strStartTime,intUseTime,clsPage,strShowTemp
    strStartTime = timer()
    %>
    <!--#include file="inc_clsPages.asp"-->
    <%
    '分页显示的位置:SW_intPageInAll,SW_intPageInTop,SW_intPageInBottom
    '页数的显示模式:SW_intShowChinese,SW_intShowEnglish,SW_intShowCharacter,SW_intShowImage


    '页面显示模板设置 <文件头> + <页数设置:分页显示模式,页数显示的位置> + <数据显示> + <页数显示> + <文件尾>如果某项不需要,只要设置成<>就行了,不过<文件头>和<文件尾是必须的>

    '设置分页文件头,可以直接跟HTML代码({code=....})
    strShowTemp = "[file=head.js] + "
    '设置分页条显示信息
    strShowTemp = strShowTemp & "[page=" & SW_intPageInAll & "," & SW_intShowCharacter & "] + "

    '########设置数据模版信息
    strShowTemp = strShowTemp & "[data="
    '设置显示的宽度
    strShowTemp = strShowTemp & "90%|"
    '数据显示方式,竖排、横排
    strShowTemp = strShowTemp & SW_intVerticalView & "|"

    '需要显示的字段的相应的中文说明
    strShowTemp = strShowTemp & "编号,用户名,生日#"
    '需要显示的字段的相应的对齐方式
    strShowTemp = strShowTemp & "left,center,right#"
    '需要显示的字段的相应的宽度
    strShowTemp = strShowTemp & "30%,30%,30%#"
    '需要显示的字段的相应的链接文件名
    strShowTemp = strShowTemp & "list.asp,,,"

    strShowTemp = strShowTemp & "] + "
    '#########数据模版结束

    '#########设置文件尾
    strShowTemp = strShowTemp & "[file=foot.js]"

    Set clsPage = New SWPage
    clsPage.Conn = "Driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.Mappath("../db/datatest.mdb"
    clsPage.SQL = "SELECT * FROM datatest"
    clsPage.PageSize = 10
    clsPage.URL = "pages.asp"
    clsPage.FieldList = "id,field1,field2"
    clsPage.Template = strShowTemp '显示模版
    clsPage.Init()
    clsPage.Show
    clsPage.Close
    Set clsPage = Nothing

    intUseTime = FormatNumber((timer()-strStartTime)*1000,3)
    Response.Write("<br><br><center>共用时 <font color=""#FF0000"">" & intUseTime & "</font> 毫秒</center>"
    %>

    四、注意事项
      你可以随意修改、使用此代码,但是当你修改后,希望能给我一份拷贝(cjj8110@xxx163.com为了防止垃圾邮件,发邮件时请把163前面的"xxx"删除)。如在使用中发现有Bug请通知我或帮我改正,需要注意的是本类需要用到FSO,主要是URL属性中用到它。现在不使有RecordSet对象的RecordCount属性来获取总记录数了,而是将总记录数存在另外的一个表中,所以在通用方面降低了很多,有兴趣的朋友也可以用Application对象来记录总记录数。不管哪种方法,都使添加记录、删除记录的操作麻烦起来了,但分页中最耗时的地方就是用RecordCount来取总记录数了,当然如果你的库记录数不多的话,是无所谓的。但如果有几十或几百万条记录时,可以很明显的感觉到用不用RecordCount的区别了。


    microci 发表于 >2004-11-17 14:59:03 [全文] [评论] [引用] [推荐] [档案] [推给好友]

    2004-11-17
    ASP通用分页类 v2.8

    一、类的属性、方法
      这是一个ASP通用分页类。你可以用它方便的给记录集分页,当然在网上有许多的分页类和分页函数。本分页主要有Conn、SQL、URL、FieldList、PageSize、Template、Init、Show、Close等属性和方法。
      1.Conn属性    :用来获取一个已创建的Connection对象。
      2.SQL属性      :根据传入的SQL语句,自动创建RecordSet对象
      3.PageSize属性   :设置第页的记录条数
      4.FieldList属性    :如果需要显示库中的数据,一定要设置此属性。它是用来获取需要显示的正确的字段名。
      5.URL属性     :设置分页条中链接的文件地址。
      6.Template属性   :设置分页文件的模版。
      7.Init过程     :分页类初始化数据。
      8.Show过程   :显示数据。
      9.Close过程    :分页类结束

    全部代码由此下载

    二、类的源代码(inc_clsPage.asp)

    <%
    '/************************************************
    '* *
    '* Name : Asp pagnation class *
    '* Author : cjj *
    '* Version : V2.8 *
    '* Time : 2004-01-16 *
    '* Comefrom:http://www.blueidea.com/ *
    '* HomePage: None (Maybe Soon) *
    '* Notice : You can use and modify it freely, *
    '* BUT PLEASE HOLD THIS ITEM. *
    '* If you modify it that i hope you *
    '* can send a mail for me. *
    '* *
    '************************************************/

    '#########声明变量#########

    '定义链接的显示类型
    Const SW_intShowChinese = 0 '汉字,如"上一页、下一页"
    Const SW_intShowEnglish = 1 '英文,如"Back、Next"
    Const SW_intShowCharacter = 2 '特殊字符
    '定义数据的显示类型
    Const SW_intHorizontalView = 0 '横排
    Const SW_intVerticalView = 1 '竖排
    '线的显示类型
    Const SW_intShowBigBorder = 2 '粗线
    Const SW_intShowSmallBorder = 1 '细线
    Const SW_intShowNoBorder = 0 '无线

    '标题栏线的显示类型
    Const SW_intTleSmallBorder = 1 '细线
    Const SW_intTleNoBorder = 0 '无线

    '显示分页信息的位置
    Const SW_intPageInNone = 0 '不显示分页条
    Const SW_intPageInTop = 1 '在顶部显示
    Const SW_intPageInBottom = 2 '在底部显示
    Const SW_intPageInAll = 3 '在顶、底部显示

    '显示的页数的数字个数
    Const SW_intShowPages = 10

    'SWPage Class
    Private SW_blnIsHaveRS,SW_strFields,SW_blnInConn,SW_intShowPagePos,SW_strShowWidth
    '#########初始化变量##########
    SW_blnIsHaveRS = false '设置记录集获取标志为Fasle,就是无记录集状态
    SW_strShowWidth = "90%" '默认的显示宽度为90%
    SW_strFields = ""
    SW_blnInConn = true '由内部创建Connection,如果设为False则由外部创建
    SW_intShowPagePos = SW_intPageInAll


    '*****************************************
    ' 类型: 类
    ' 目的: 给记录集分页
    '*****************************************
    Class SWPage
    '声明类私有变量
    Private SW_objRS,SW_objConn

    Private SW_strSQL,SW_strURL,SW_strError,SW_strFormAction,SW_strHeadJS,SW_strFootJS

    Private SW_intPageSize,SW_intTleBDType,SW_intShowPageType,SW_intShowType
    Private SW_lngTotalPage,SW_lngTotalRecord,SW_lngPageNo
    Private SW_aryFldName,SW_aryFldNote,SW_aryFldWidth,SW_aryFldAlign,SW_aryFldLink
    Private SW_blnInit,SW_blnOpenRS,SW_blnConn,SW_blnPageSize,SW_blnFieldList,SW_blnGetURL,SW_blnShowType,SW_blnShowPageType,SW_blnTemplate

    '*****************************************
    ' 类型: 属性
    ' 目的: 根据获取的信息,创建数据库连接
    ' 输入: a_strConn:数据类型字符串
    ' 返回: 无
    '*****************************************
    Public Property Let Conn(a_strConn)
    Dim strError
    SW_blnConn = false
    Set SW_objConn = CreateObject("Adodb.Connection"
    On Error Resume Next
    SW_objConn.Open a_strConn
    If Err.Number <> 0 Then strError = strError & "<br>创建Connection对象失败"
    On Error Goto 0

    If Trim(strError)="" Then
    SW_blnConn = true
    Else
    SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">Conn属性:</font></td></tr>" & vbcrlf
    SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf
    End If
    End Property

    '*****************************************
    ' 类型: 属性
    ' 目的: 设定或显示SQL语句。
    ' 输入: a_strSQL: SQL语句。
    ' 返回: SQL语句。
    '*****************************************
    Public Property Let SQL(a_strSQL)
    Dim strError

    SW_blnOpenRS = false
    SW_strSQL = a_strSQL

    '创建RecordSet对象
    Set SW_objRS = CreateObject("adodb.RecordSet"
    On Error Resume Next
    SW_objRS.Open SW_strSQL,SW_objConn,1,1
    If Err.Number <> 0 Then strError = "<br>记录集打开失败"
    On Error Goto 0

    If Trim(strError)="" Then
    SW_blnOpenRS = true
    Else
    SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">SQL属性:</font></td></tr>" & vbcrlf
    SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf
    End If
    End Property


    '*****************************************
    ' 类型: 属性
    ' 目的: 设置需要显示的数据的字段名
    ' 输入: a_strFldName:字段名字符串,多个字段之间以逗号分隔
    ' 返回: 无
    '*****************************************
    Public Property Let FieldList(a_strFldName)
    Dim strError

    SW_blnFieldList = false
    If Trim(a_strFldName) <> "" Then
    SW_aryFldName = Split(LCase(a_strFldName),","
    Else
    strError = strError & "<br>你必须设置需要显示的字段名,否则无法显示数据"
    End If
    If Trim(strError)="" Then
    SW_blnFieldList = true
    Else
    SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">FieldList属性:</font></td></tr>" & vbcrlf
    SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf
    End If
    End Property

    '*****************************************
    ' 类型: 属性
    ' 目的: 设定或显示每页的记录数。
    ' 输入: a_intPageSize: 每页显示的记录数。
    ' 返回: 每页显示的记录数。
    '*****************************************
    Public Property Let PageSize(a_intPageSize)
    Dim strError

    'PageSize获取失败标志
    SW_blnPageSize = false
    If Trim(a_intPageSize) = "" OR (Not(IsNumeric(a_intPageSize))) Then
    strError = strError & "<br>非法的pagesize"
    Else
    If (a_intPageSize <= 2147483647 And a_intPageSize>=-2147483648) Then
    SW_intPageSize = CLng(a_intPageSize)
    Else
    strError = strError & "<br>PageSize溢出"
    End If
    If (SW_intPageSize<=0) Then
    strError = strError & "<br>PageSize只能是正整数"
    End If
    End If
    If Trim(strError)="" Then
    SW_blnPageSize = True
    Else
    SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">PageSize属性:</font></td></tr>" & vbcrlf
    SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf
    End If
    End Property

    '*****************************************
    ' 类型: 属性
    ' 目的: 设定分页文件显示模板信息。
    ' 输入: a_strTemplate: 模板描述。
    ' 返回: 无。
    '*****************************************
    Public Property Let Template(a_strTemplate)
    Dim aryTemplate,i,j,strError,strTemp,intItem,aryTemp,aryTemp1

    SW_blnTemplate = false

    aryTemplate = Split(Trim(LCase(a_strTemplate)),"+"
    intItem = UBound(aryTemplate)
    If intItem < 4 Then strError = "<br>此属性是必选项"

    If intItem < 4 Then
    '获取文件头
    strTemp = TriM(aryTemplate(0))

    If strcomp(Left(strTemp,6),"[file="= 0 Then
    SW_strHeadJS = "<script src=""" & Mid(strTemp,7,Len(strTemp)-7) & """>"
    Else
    SW_strHeadJS = Mid(strTemp,7,Len(strTemp)-7)
    End If

    '获取文件尾
    strTemp = Trim(aryTemplate(3))

    If strComp(Left(strTemp,6),"[file=" = 0 Then
    SW_strFootJS = "<script src=""" & Mid(strTemp,7,Len(strTemp)-7) & """>"
    Else
    SW_strFootJS = Mid(strTemp,7,Len(strTemp)-7)
    End If

    '获取分页模版
    aryTemp = Split(aryTemplate(1),","
    If aryTemp(0) <> "" Then strTemp = Replace(aryTemp(0),"[page=",""

    If IsNumeric(strTemp) Then strTemp = CInt(strTemp)
    If strTemp <> SW_intPageInNone Then

    If IsNumeric(strTemp) Then strTemp = CInt(strTemp)

    SW_intShowPagePos = strTemp
    strTemp = aryTemp(1)
    If strTemp <> "" Then strTemp = Replace(strTemp,"]",""

    If IsNumeric(strTemp) Then strTemp = CInt(strTemp)
    SW_intShowPageType = strTemp
    Else
    SW_intShowPagePos = SW_intPageShowInNone
    End If

    '获取数据显示模版
    aryTemp = Split(aryTemplate(2),"|"
    For i = 0 To UBound(aryTemp)
    strTemp = LCase(Trim(aryTemp(i)))
    Select Case i
    Case 0 '获取并设置显示宽度
    If strTemp <> "" Then strTemp = Replace(strTemp,"[data=",""
    SW_strShowWidth = strTemp
    Case 1 '获取数据显示方式
    If IsNumeric(strTemp) Then strTemp = CInt(strTemp)
    SW_intShowType = strTemp
    Case 2
    If strTemp <> "" Then strTemp = Replace(strTemp,"]",""
    aryTemp1 = Split(Trim(strTemp),"#"
    If UBound(aryTemp1) >= 3 Then
    SW_aryFldNote = Split(aryTemp1(0),","
    SW_aryFldAlign = Split(aryTemp1(1),","
    SW_aryFldWidth = Split(aryTemp1(2),","
    SW_aryFldLink = Split(aryTemp1(3),","
    End If
    End Select
    Next
    End If

    If strError = "" Then
    SW_blnTemplate = true
    Else
    SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">Template属性:</font></td></tr>" & vbcrlf
    SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf
    End If
    End Property

    '*****************************************
    ' 类型: 属性
    ' 目的: 设定或显示URL。
    ' 输入: a_strURL: 需要分页的文件地址。
    ' 返回: 需要分页的文件地址。
    '*****************************************
    Public Property Let URL(a_strURL)
    Dim strError,objFSO

    SW_blnGetURL = false
    If Trim(a_strURL)="" Then
    strError = "<br>非法的URL地址"
    Else
    Set objFSO = CreateObject("Scripting.FileSystemObject"
    If objFSO.FileExists(Server.Mappath(a_strURL)) Then
    SW_strURL = a_strURL
    Else
    strError = strError & "<br>你能确定文件 <font color=""#ff0000"">" & a_strURL & "</font> 存在么?"
    End If
    Set objFSO = Nothing
    End If
    If strError = "" Then
    SW_blnGetURL = true
    Else
    SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">URL属性:</font></td></tr>" & vbcrlf
    SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf
    End If
    End Property


  • 相关阅读:
    css(完)
    HTML学习(完)
    leetcode学习03
    多线程详解2(完)
    windows7 64位下安装apache和php
    一个js,记录方便查询。
    用了锚的时候,有的层被覆盖了。
    日,在ie10下面hover里不能控制table
    在实现tab的时候,margin-bottom:-1px无效的问题
    javascript中,在一个类里attache的event事件中,如果调用类的成员变量和方法
  • 原文地址:https://www.cnblogs.com/rxbook/p/5999646.html
Copyright © 2011-2022 走看看