Chinaunix首页 | 论坛 | 博客
  • 博客访问: 375961
  • 博文数量: 152
  • 博客积分: 6020
  • 博客等级: 准将
  • 技术积分: 850
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-11 19:20
文章分类

全部博文(152)

文章存档

2017年(1)

2010年(1)

2007年(3)

2006年(147)

我的朋友

分类:

2006-04-09 21:46:55

     1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键
  no 可用于Table

  2.  取消选取、防止复制

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

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

  5.  IE地址栏前换成自己的图标

  6.  可以在收藏夹中显示出你的图标

  7.  关闭输入法

  8. 永远都会带着框架
  

  9. 防止被人frame
  

  10. 网页将不能被另存为
   

  11.   onclick="window.location = "view-source:"+ "

  12.删除时确认
  删除 

  13. 取得控件的绝对位置
  //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
  

  14. 光标是停在文本框文字的最后
  
  function cc()
  {
  var e = event.srcElement;
  var r =e.createTextRange();
  r.moveStart("character",e.value.length);
  r.collapse(true);
  r.select();
  }
  
  

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

  16. 最小化、最大化、关闭窗口
   
  
   
  
  
  
  
  
  
  本例适用于IE
  

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

  18. 网页不会被缓存
  
  
  
  或者

  19.怎样让表单没有凹凸感?
   
  或
  
  1 solid #000000">

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


  21.让弹出窗口总是在最上面:
  

  22.不要滚动条? 
  让竖条没有: 
   
   
  让横条没有: 
   
   
  两个都去掉?更简单了 
   
   

  23.怎样去掉图片链接点击后,图片周围的虚线?
  

  24.电子邮件处理提交表单
   
  
  

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

  26.如何设定打开页面的大小
  
  打开页面的位置

  27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动 
   

  28. 检查一段字符串是否全由数字组成
  

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

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

  31.TEXTAREA自适应文字行数的多少
  
  
  

  32. 日期减去天数等于第二个日期
  
  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
  
  function checkme()
  for each ob in radio1
  if ob.checked then window.alert ob.value
  next
  end function
  
  Style
  Barcode
  
  

  34.脚本永不出错
   
   
  

  35.ENTER键可以让光标移到下一个输入框
  

  36. 检测某个网站的链接速度:
  把如下代码加入区域中:
  
  tim=1
  setInterval("tim++",100)
  b=1
  var autourl=new Array()
  autourl[1]=""
  autourl[2]=""
  autourl[3]=""
  autourl[4]=""
  autourl[5]=""
  function butt(){
  document.write("")
  for(var i=1;i  document.write(" =》  name=url"+i+" size=40> =》
  onclick=window.open(this.form.url"+i+".value)>
")
  document.write("")
  }
  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
  onerror=auto("}
  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.页面进入和退出的特效
  进入页面
  推出页面  
  这个是页面被载入和调出时的一些特效。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.在规定时间内跳转
   

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

loading... 
 

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

pagetest.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  response.write oRs(1)&"
"
  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 "<<上一页"
  else
   response.write "<<上一页"
  end if
 end if
 for i=minpage to maxpage
  if(cint(i)=cint(currentpage)) then
   response.write "["&i&"]"
  else
   response.write "["&i&"]"
  end if
 next
 if(cint(pagesum-currentpage)>0) then
  response.write "下一页>>"
 end if
 response.write "
"

'以下是另一种分页显示界面
 if currentpage=1 then
  Response.Write " [最前页]"
  Response.Write "[上一页]"
 else
  Response.Write "[最前页]"
  Response.Write "[上一页]"
 End If

 '如果是最后一页

 If cint(currentpage)  Response.Write "[下一页]"
  Response.Write "[最末页]" 
 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   
 
%>

loading... 
 

2005-1-5
JS经典技巧

 1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键
    no 可用于Table

  2.  取消选取、防止复制

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

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

  5.  IE地址栏前换成自己的图标

  6.  可以在收藏夹中显示出你的图标

  7.  关闭输入法

  8. 永远都会带着框架
  

  9. 防止被人frame
  

  10. 网页将不能被另存为
   

  11.   onclick="window.location = "view-source:"+ " 

  12.删除时确认
  删除 

  13. 取得控件的绝对位置
  //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
  

  14. 光标是停在文本框文字的最后
  
  function cc()
  {
  var e = event.srcElement;
  var r =e.createTextRange();
  r.moveStart("character",e.value.length);
  r.collapse(true);
  r.select();
  }
  
  

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

  16. 最小化、最大化、关闭窗口
   
  
   
  
  
  
  
  
  
  本例适用于IE
  

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

  18. 网页不会被缓存
  
  
  
  或者

  19.怎样让表单没有凹凸感?
   
  或
  
  1 solid #000000">

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


  21.让弹出窗口总是在最上面:
  

  22.不要滚动条? 
  让竖条没有: 
   
   
  让横条没有: 
   
   
  两个都去掉?更简单了 
   
   

  23.怎样去掉图片链接点击后,图片周围的虚线?
  

  24.电子邮件处理提交表单
   
  
  

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

  26.如何设定打开页面的大小
  
  打开页面的位置

  27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动 
   

  28. 检查一段字符串是否全由数字组成
  

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

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

  31.TEXTAREA自适应文字行数的多少
  
  
  

  32. 日期减去天数等于第二个日期
  
  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
  
  function checkme()
  for each ob in radio1
  if ob.checked then window.alert ob.value
  next
  end function
  
  Style
  Barcode
  
  

  34.脚本永不出错
   
   
  

  35.ENTER键可以让光标移到下一个输入框
  

  36. 检测某个网站的链接速度:
  把如下代码加入区域中:
  
  tim=1
  setInterval("tim++",100)
  b=1
  var autourl=new Array()
  autourl[1]=""
  autourl[2]=""
  autourl[3]=""
  autourl[4]=""
  autourl[5]=""
  function butt(){
  document.write(""
  for(var i=1;i  document.write(" =》  name=url"+i+" size=40> =》
  onclick=window.open(this.form.url"+i+".value)>
"
  document.write(""
  }
  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
  onerror=auto(" }
  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.页面进入和退出的特效
  进入页面
  推出页面  
  这个是页面被载入和调出时的一些特效。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.在规定时间内跳转
    

  40.网页是否被检索
  
  其中属性值有以下一些:
  属性值为"all": 文件将被检索,且页上链接可被查询;
  属性值为"none": 文件不被检索,而且不查询页上的链接;
  属性值为"index": 文件将被检索;
  属性值为"follow": 查询页上的链接;
  属性值为"noindex": 文件不检索,但可被查询链接;
  属性值为"nofollow": 文件不被检索,但可查询页上的链接。 
loading... 
 
阅读(552) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~