万升's profile小鲍的成长日志PhotosBlogLists Tools Help
Photo 1 of 2
More albums (1)

苦力 鲍

Occupation
11/7/2005

改变文字

<SCRIPT LANGUAGE="JAVASCRIPT">

//n = (document.layers) ? 1:0
//ie = (document.all) ? 1:0

function change_content(divname, newtext) {
    //if (n) {
       // document.layers[divname].document.write(newtext)
       // document.layers[divname].document.close()
    //}
   // if (ie)
 document.all[divname].innerHTML = newtext
}

</SCRIPT>
<a href="#" tppabs="#" onMouseMove="change_content('layer1', '→')" onMouseOut="change_content('layer1', '□')"">
Change the current text to "This is the new text!"
</A><BR>

<span ID="layer1">

</span>

10/21/2005

JS定义Title样式

//防止错误出现
function killErrors() {
return true;}
window.onerror = killErrors;
var pltsPop=null;
var pltsoffsetX = 10;   // 弹出窗口位于鼠标左侧或者右侧的距离;3-12 合适
var pltsoffsetY = 15;  // 弹出窗口位于鼠标下方的距离;3-12 合适
var pltsPopbg="#FFFFEE"; //背景色
var pltsPopfg="#000000"; //前景色
var pltsTitle="cvvvv";
document.write('<div id=pltsTipLayer style="display: none;position: absolute; z-index:10001"></div>');
function pltsinits()
{document.onmouseover=plts;
document.onmousemove=moveToMouseLoc;}
function plts()
{var o=event.srcElement;
if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
pltsPop=o.dypop;
if(pltsPop!=null&&pltsPop!=""&&typeof(pltsPop)!="undefined")
{pltsTipLayer.style.left=-1000;
pltsTipLayer.style.display='';
var Msg=pltsPop.replace(/\n/g,"<br>");
Msg=Msg.replace(/\0x13/g,"<br>");
var re=/\{(.[^\{]*)\}/ig;
if(!re.test(Msg))pltsTitle="安徽家教网提醒您!";
else{
re=/\{(.[^\{]*)\}(.*)/ig;
pltsTitle=Msg.replace(re,"$1")+"&nbsp;";
re=/\{(.[^\{]*)\}/ig;
Msg=Msg.replace(re,"");
Msg=Msg.replace("<br>","");}
var content =
'<table style="background:ffffff;border:1px solid #444444" id=toolTipTalbe><tr id=pltsPoptop><th id=topleft><p id=topright style="display:none"></th></tr><tr><td  style="padding:0px;line-height:135%">'+Msg+'</td></tr>'+
'<tr id=pltsPopbot style="display:none"><th><p id=botleft></p><p id=botright align=rightstyle="display:none"></th></tr></table>';
pltsTipLayer.innerHTML=content;
toolTipTalbe.style.width=Math.min(pltsTipLayer.clientWidth,document.body.clientWidth/2.2);
moveToMouseLoc();
return true;}else{pltsTipLayer.innerHTML='';
pltsTipLayer.style.display='none';
return true;}}
function moveToMouseLoc()
{if(pltsTipLayer.innerHTML=='')return true;
var MouseX=event.x;
var MouseY=event.y;
//window.status=event.y;
var popHeight=pltsTipLayer.clientHeight;
var popWidth=pltsTipLayer.clientWidth;
if(MouseY+pltsoffsetY+popHeight>document.body.clientHeight)
{popTopAdjust=-popHeight-pltsoffsetY*1.5;
pltsPoptop.style.display="none";
pltsPopbot.style.display="";}else{
popTopAdjust=0;pltsPoptop.style.display="";pltsPopbot.style.display="none";}
if(MouseX+pltsoffsetX+popWidth>document.body.clientWidth){
popLeftAdjust=-popWidth-pltsoffsetX*2;topleft.style.display="none";
botleft.style.display="none";
topright.style.display="";
botright.style.display="";}else
{popLeftAdjust=0;topleft.style.display="";botleft.style.display="";
topright.style.display="none";botright.style.display="none";}
pltsTipLayer.style.left=MouseX+pltsoffsetX+document.body.scrollLeft+popLeftAdjust;
pltsTipLayer.style.top=MouseY+pltsoffsetY+document.body.scrollTop+popTopAdjust;
return true;}
pltsinits();

精典JS验证用户名

<script language="JavaScript" type="text/JavaScript">
//验证用户名中是否有空格
function isWhiteWpace (s){
  var whitespace = " \t\n\r";
  var i;
  for (i = 0; i < s.length; i++){ 
   var c = s.charAt(i);
   if (whitespace.indexOf(c) >= 0) {return true;}
 }
return false;
}

//验证用户名是否合法
function isSsnString (ssn){
var re=/^[0-9a-z][\w-.]*[0-9a-z]$/i;
if(re.test(ssn)){return true;}else{return false;}
}
//验证用户名
function checkUserName(ssn){
 if( ssn.length<3 || ssn.length>18 ) {
  alert("\请输入正确的用户名,用户名长度为3-18位!")
  form_Registers.username.focus();
  return false;
 }
 if (isWhiteWpace(ssn)){
  alert("\请输入正确的用户名,用户名中不能包含空格!");
  form_Registers.username.focus();
  return false;
 }
 if (!isSsnString(ssn)){
  alert("\    对不起,您选择的用户名不正确或已被占用!\n用户名应该由不区分大小写“a-z 0-9 ._-”字符组成!");
  form_Registers.username.focus();
  return false;
 }
return true;
}
function checkssn(gotoURL) {
 var ssn=form_Registers.username.value.toLowerCase(); 
 if (checkUserName(ssn)){   
  var open_url = gotoURL + "?username=" + ssn;   
  window.open(open_url,'','status=0,directories=0,resizable=0,toolbar=0,location=0,scrollbars=0,width=322,height=200'); 
 }
}
</script>
 
 
 
===========页面中调用javascript:checkssn('index.asp')
9/21/2005

几个常用的ASP应用函数

'###############################非法字符检测函数#############################
'函数名: Chk_Lawless_Char 检查非法字符
'参  数: char 欲检查的字符
'返回值: 含有非法字符返回True,否则返回False
Function Chk_Lawless_Char(char)
 If Instr(char,"'") OR instr(char,"<") OR instr(char,">") OR instr(char,"&") OR _
    Instr(char,chr(32)) OR instr(char,chr(34)) OR instr(char,"%") OR _
    Instr(char," ") OR instr(char,"‘") Then
    Chk_Lawless_Char = True
 Else
    Chk_Lawless_Char = False
 End IF
End Function
'###############################字符长度检测函数#############################
'函数名: StrLength
'参  数: str 欲检查的字符
'返回值: 返回字符的长度
'注  意: 一个汉字为2个字符
'例  子: StrLength("我们") = 4 | StrLength("abc1") = 4
Function StrLength(str)
 If isNull(str) or Str = "" Then
  StrLength = 0
  Exit function
 End If
 If len("例子") = 2 then
  Dim l,t,c,i
  l=len(str)
  t=l
  for i=1 to l
   c=asc(mid(str,i,1))
   If c<0 then c=c+65536
   If c>255 then
    t=t+1
   End If
  next
  StrLength=t
 Else
  StrLength=len(str)
 End If
End Function

'###############################检查字符串是否由数字[0-9]构成的数#############################
'函数名: Check_Number
'参  数: str 欲检查的字符
'返回值: 返回真(True)说明字符串由数字构成,返回假说明含有非数字字符
'例  子: Check_Number("123") → True
'  Check_Number("123.5") → False 因为.不是数字
'  Check_Number("我们") → False 因为"我们"不是数字
Function Check_Number(Str)
 Dim i,j,Disassemble_Str
 Check_Number = True
 '将检测字符分解,将每个字符同0-9进行比较
 For i = 1 To Len(Str)
  Disassemble_Str = Mid(Str,i,1)
  For j = 0 To 9
   IF Disassemble_Str = CStr(j) Then Exit FOR
   IF j = 9 And Disassemble_Str <> CStr(j) Then Check_Number = False
  Next
 Next
End Function

'###############################检查人民币#############################
'函数名: Check_RMB
'参  数: str 欲检查的字符
'返回值: 如果参数由数字构成,则返回处理后的结果 (结果为: AAA.BB)
'例  子: Check_RMB("123")  → 123.00
'  Check_RMB("123.5")  → 123.50
'  Check_RMB("128.55554785") → 128.56
'  Check_RMB("dsfdsf")  → 0.01 '如果字符串含有非数字,函数返回0.01
Function Check_RMB(Str)
 Dim x
 x = InStr(1,Str,".")
 IF IsNumeric(Cstr(Str)) Then
  IF x = 0 Then
   Check_RMB = Str & ".00"
  Else
   IF Len(Str) = x Then
    Check_RMB = Str & "00"
   ElseIF Len(Str) - x = 1 Then
    Check_RMB = Str & "0"
   ElseIF Len(Str) - x > 2 Then
    Check_RMB = CLng(Str*100)/100
   Else
    Check_RMB = Str
   End IF
  End IF
 Else
  Response.Write "<Script>alert('金额必须由数字组成!');history.back();</Script>"
  Response.End
  'Check_RMB = "0.01"
 End IF
  
End Function

'***************************************************
'函数名:IsObjInstalled
'作  用:检查组件是否已经安装
'参  数:strClassString ----组件名
'返回值:True  ----已经安装
'        False ----没有安装
'***************************************************
Function IsObjInstalled(strClassString)
 On Error Resume Next
 IsObjInstalled = False
 Err = 0
 Dim xTestObj
 Set xTestObj = Server.CreateObject(strClassString)
 If 0 = Err Then IsObjInstalled = True
 Set xTestObj = Nothing
 Err = 0
End Function

'***********************************************
'函数名:JoinChar
'作  用:向地址中加入 ? 或 &
'参  数:strUrl  ----网址
'返回值:加了 ? 或 & 的网址
'***********************************************
function JoinChar(strUrl)
 if strUrl="" then
  JoinChar=""
  exit function
 end if
 if InStr(strUrl,"?")<len(strUrl) then
  if InStr(strUrl,"?")>1 then
   if InStr(strUrl,"&")<len(strUrl) then
    JoinChar=strUrl & "&"
   else
    JoinChar=strUrl
   end if
  else
   JoinChar=strUrl & "?"
  end if
 else
  JoinChar=strUrl
 end if
end function

function SqlEncode(str)
     SqlEncode="'" & replace(str,"'","''") & "'"
end function

Function Save_Pic()
 dim request2,formPath,formName,intTemp,Bws_Pic_Src,Pic_Default
 Dim admin_file '设置管理文件夹
 set request2=new UpLoadClass     '建立上传对象
'-----------------------------------请在应用时配置以下文件----------------------------------
 request2.FileType = "gif/jpg/png/jpeg/bmp"   '设置文件允许的附件类型为gif/jpg/rar/zip 
 request2.MaxSize  = 150*1024      '设置文件允许上传的大小(k)
 request2.SavePath = "uploadfile/UploadFile/"  '设置服务器文件保存路径
 Pic_Default  = "uploadfile/UploadFile/none.gif" '设置错误时上传的默认值 
 admin_file  = "manage/"    '设置管理文件夹名
'-----------------------------------------配 置 结 束----------------------------------
 request2.open()       '打开对象
 Bws_Pic_Src=""
 FOR intTemp=1 TO Ubound(request2.FileItem)
  formName=request2.FileItem(intTemp)
  select case request2.form(formName&"_Err")  '显示文件保存状态
   case -1: '没有文件上传
    Bws_Pic_Src=Bws_Pic_Src & admin_file & Pic_Default & "|" 
   case 0:  '上传文件成功
    Bws_Pic_Src=Bws_Pic_Src & admin_file & request2.SavePath & request2.form(formName) & "|" 
   case 1:  '文件太大,拒绝上传
    Bws_Pic_Src=Bws_Pic_Src & admin_file & Pic_Default & "|" 
   case 2:  '文件格式不对,拒绝上传
    Bws_Pic_Src=Bws_Pic_Src & admin_file & Pic_Default & "|" 
   case 3:  '文件太大且格式不对,拒绝上传
    Bws_Pic_Src=Bws_Pic_Src & admin_file & Pic_Default & "|"
  end select
 Next
 Bws_Pic_Src = left(Bws_Pic_Src,len(Bws_Pic_Src)-1)
 Save_Pic=Bws_Pic_Src
End Function
Function YD_Price(Price,Msg,PriceName)
 IF Price = "" Then
  ErrMsg = ErrMsg & "<br><li>" & Msg & "不得为空!</li>"
 Else
  IF Not IsNumeric(Cstr(Price)) Then
   ErrMsg = ErrMsg & "<br><li>" & Msg & "不得含有中文或其它特殊字符!</li>"
  Else
   IF Price <= 0 Then
    ErrMsg = ErrMsg & "<br><li>" & Msg & "不得为负数!</li>"
   Else
    Response.Cookies("YD_Suosams")("" & PriceName & "") = Check_RMB(Price) '保留2位小数,四舍五入
   End IF
  End IF
 End IF
 YD_Price = ErrMsg
End Function
%>
9/17/2005

超酷原创JS下拉列表导航

<link href="inc/css.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
var x=7;//这里的X等于t(txt,n)的个数
var pic_habitus=0;//这里设置上面图片的初始值
function showtb(tbnum){
 var whichEl = eval("tbtype" + tbnum);
 var Bws_Num = eval(tbnum);
 var x=7;//这里的X等于t(txt,n)的个数
 if (whichEl.style.display == "none"){
  eval("tbtype" + tbnum + ".style.display=\"\";");
  eval("file_"+ tbnum +".src=\"images/icon-folder1-open.gif\";")
  eval("list_"+ tbnum +".src=\"images/icon-folder-open.gif\";")
   for(i=1;i<x+1;i++){
    if(i!=Bws_Num){
     eval("tbtype" + i + ".style.display=\"none\";")
     eval("file_"+ i +".src=\"images/icon-folder1-close.gif\";")
     eval("list_"+ i +".src=\"images/icon-folder-close.gif\";")
    }
   }
 }else{
  eval("tbtype" + tbnum + ".style.display=\"none\";");
  eval("file_"+ tbnum +".src=\"images/icon-folder1-close.gif\";")
  eval("list_"+ tbnum +".src=\"images/icon-folder-close.gif\";")
 }
}
function expandall(bb){
 pic_habitus
 if(pic_habitus==0){
   for(i=1;i<x+1;i++){
   eval("tbtype" + i + ".style.display=\"\";");
   eval("file_"+ i +".src=\"images/icon-folder1-open.gif\";")
   eval("list_"+ i +".src=\"images/icon-folder-open.gif\";")
   }
   pic_habitus=1;
   bb.src="images/icon-expandall.gif";
   bb.alt="全部关闭";
 }else{
   for(i=1;i<x+1;i++){
   eval("tbtype" + i + ".style.display=\"none\";");
   eval("file_"+ i +".src=\"images/icon-folder1-close.gif\";")
   eval("list_"+ i +".src=\"images/icon-folder-close.gif\";")
   }
   pic_habitus=0;
   bb.src="images/icon-closeall.gif";
   bb.alt="全部展开";
 }
}
function t(txt,n){
document.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"borderon\"><tr><td height=\"20\" style=\"padding-left:10px;CURSOR: hand\" onclick=showtb("+ n +")><img src=\"images/icon-folder1-close.gif\"width=\"15\" height=\"13\" name=\"file_"+n+"\"><img src=\"images/icon-folder-close.gif\" width=\"16\" height=\"15\" name=\"list_"+n+"\">"+txt+"</td></tr><tbody style=\"display=none\" id=\"tbtype"+ n +"\">")
}
function list(url,target,txt){
document.write("<tr><td height=\"20\" style=\"padding-left:13px\"><img src=\"images/line.gif\" width=\"13\" height=\"18\" align=\"absmiddle\"><a href=\""+ url +"\" target="+target+">"+ txt +"</td></tr>")
}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="borderon">
<tr>
<td height="40" align="center">后台管理系统 V1.0版
<img src="images/icon-closeall.gif" alt="全部展开" width="16" height="15" vspace="2" align="absmiddle" class="button" onclick="expandall(this)">
</td>
</tr>
</table>
<script>
t("网站管理",1)
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
t("商品管理",2)
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
t("会员管理",3)
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
t("会员管理",4)
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
t("会员管理",5)
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
t("会员管理",6)
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
t("会员管理",7)
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
list("http://www.kl21.com","_blank","首页基本配置")
</script>