IT学习者 | 文章大全 | 技术文档 | 桌面壁纸 | 实用查询 | 网络电台 | 成语 | 歇后语 | 网址 | 下载 | 周公解梦 | 生日密码 | 电视剧365 | Flash
 您现在的位置: IT学习者 >> 文章大全 >> 网页制作 >> 网页特效代码

JavaScript通用库(二)

【 来源:VisualSW  更新时间:2006-1-18 | 字体:

/*

IsEnLetter(string,string):测试字符串,大小写(UL,U,L or ul,u,l)

*/

function IsEnLetter(objStr,size)

{

    var reg;

   

    if(Trim(objStr)=="")

    {

        return false;

    }

    else

    {

        objStr=objStr.toString();

    }   

   

    if((size==null)||(Trim(size)==""))

    {

        size="UL";

    }

    else

    {

        size=size.toUpperCase();

    }

   

    switch(size)

    {

        case "UL":

            //大小写

            reg=/^[A-Za-z]+$/;

            break;

        case "U":

            //大写

            reg=/^[A-Z]+$/;

            break;

        case "L":

            //小写

            reg=/^[a-z]+$/;

            break;

        default:

            alert("检查大小写参数,只可为(空、UL、U、L)");

            return false;

            break;

    }

   

    var r=objStr.match(reg);

    if(r==null)

    {

        return false;

    }

    else

    {       

        return true;    

    }

}

 

 

/*

================================================================================

功能:鼠标小提示

作者:申旺

日期:2004/04/15

================================================================================

*/

 

//定义变量、设置默认值

var LabelFontFace="宋体,arial,Verdana";

var LabelFontColor="#000000";

var LabelFontSize="9pt";

var LabelFontStyle="Font.PLAIN";

var LabelBorderColor="#000000";

var LabelBackColor="#FFFFE1";

 

//设置各个属性

function SetLabelFontFace(obj)

{

       obj=Trim(obj);

       if(obj==null || obj=="")

       {

              obj="宋体,arial,Verdana";

       }

       LabelFontFace=obj;

}

 

function SetLabelFontColor(obj)

{

    obj=Trim(obj);

       if(obj==null || obj=="")

       {

              obj="#000000";

       }

       LabelFontColor=obj;

}

 

function SetLabelFontSize(obj)

{

    obj=Trim(obj);

       if(obj==null || obj=="")

       {

              obj="9pt";

       }

       LabelFontSize=obj;

}

 

function SetLabelFontStyle(obj)

{

    obj=Trim(obj);

       if(obj==null || obj=="")

       {

              obj="Font.PLAIN";

       }

       LabelFontStyle=obj;

}

 

function SetLabelBorderColor(obj)

{

    obj=Trim(obj);

    if(obj==null || obj=="")

    {

        obj="#000000";

    }

    LabelBorderColor=obj;

}

 

function SetLabelBackColor(obj)

{

    obj=Trim(obj);

    if(obj==null || obj=="")

    {

        obj="#FFFFE1";

    }

    LabelBackColor=obj;

}

 

//合成文字样式

function SetTextStyle(str)

{

    var strRet="";

   

    var strStyle="";

   

    strStyle="font-family:"+LabelFontFace+";";

    strStyle+="color:"+LabelFontColor+";";

    strStyle+="font-size:"+LabelFontSize+";";

   

    switch(LabelFontStyle.toLowerCase())

    {

        case "font.plain":

            strStyle+="font-weight: normal;";

            strStyle+="font-style: normal;";

            break;

        case "font.bold":

            strStyle+="font-weight: bold;";

            strStyle+="font-style: normal;";

            break;

        case "font.italic":

            strStyle+="font-weight: normal;";

            strStyle+="font-style: italic;";

            break;

        case "font.italicbold":

        case "font.bolditalic":

            strStyle+="font-weight: bold;";

            strStyle+="font-style: italic;";

            break;

        default:

            strStyle+="font-weight: bold;";

            strStyle+="font-style: italic;";

            break;

    }

   

    strRet="<font style='"+strStyle+"'>";

    strRet+="&nbsp;"+str+"&nbsp;";

    strRet+="</font>";

   

    return strRet;

}

 

//合成表格样式

function SetTableStyle()

{

    var strRet="";

   

    strRet+="border-right: "+LabelBorderColor+" 1px solid;";

    strRet+="border-top: "+LabelBorderColor+" 1px solid;";

    strRet+="border-left: "+LabelBorderColor+" 1px solid;";

    strRet+="border-bottom: "+LabelBorderColor+" 1px solid;";

    strRet+="background-color:"+LabelBackColor;   

   

    return strRet;

}

 

//显示提示

function ShowNote(str)

{

       var strHtml;

      

       strHtml="";

       strHtml+="<table height=1px width=1px border='0'cellspacing='0' cellpadding='0' style='" + SetTableStyle() + "'>";

       strHtml+="<tr>";

       strHtml+="<td>"+SetTextStyle(str)+"</td>";

       strHtml+="</tr>";

       strHtml+="</table>";                          

      

       if (document.all&&document.readyState=="complete")

       {                                       

              document.all.div_Note.innerHTML=strHtml;

              document.all.div_Note.style.pixelLeft=event.clientX+document.body.scrollLeft+10

              document.all.div_Note.style.pixelTop=event.clientY+document.body.scrollTop+10

              document.all.div_Note.style.visibility="visible"

       }    

}

 

//隐藏提示

function HideNote()

{

       if (document.all)

       {

              document.all.div_Note.style.visibility="hidden";

       }

       else

       {

              if (document.layers)

              {

                     clearInterval(currentscroll)

                     document.div_Note.visibility="hidden";

              }

       }                                

}

 

//初始化

function Init()

{

    window.document.write("<div id=\"div_Note\" style=\"VISIBILITY:hidden; POSITION:absolute; HEIGHT:13px;z-index:1\"></div>");

}

Init();

 

//生成提示字符

function ShowLabel(text,note,bclick)

{

       if(bclick!=null)

       {

              return "<a href=\"#\" onMouseOver=\"ShowNote('" + note + "')\" onMouseOut=\"HideNote()\" onClick=\"javascript:DoSomeThing(this);\">" + text + "</a>";

       }

       else

       {

           return "<a href=\"#\" onMouseOver=\"ShowNote('" + note + "')\" onMouseOut=\"HideNote()\">" + text + "</a>";

       }

}

 

 

 

测试页面:

<HTML>

    <HEAD>

        <title>Common javascript</title>

              <script language="javascript" src="./Common.js"></script>

        <script language="javascript">     

                     function CheckInt()

                     {

                            iptResult.value=IsInt(iptTest.value,iptSign.value,iptZero.value);

                     }

                    

                     function CheckFloat()

                     {

                            iptResult.value=IsFloat(iptTest.value,iptSign.value,iptZero.value);

                     }

                    

                     function CheckLetter()

                     {

                            iptResult.value=IsEnLetter(iptTest.value,iptSign.value);

                     }

                     document.write(ShowLabel("TEST","Only a testing!"));

                     document.write("<br>");

              </script>

        <meta http-equiv="expires" content="0">       

    </HEAD>

    <body>   

     <input type=text value="" id="iptTest"><input type=button value="IsEmpty" onclick="IsEmpty('iptTest');">

     <input type=button value="CheckInt" onclick="CheckInt()">

        <br>

     <input type=text value="" id="iptSign" NAME="iptSign"><input type=button value="CheckFloat" onclick="CheckFloat()">

        <br>

     <input type=text value="" id="iptZero" NAME="iptZero"><input type=button value="CheckLetter" onclick="CheckLetter()">    

     <br>

     <input type=text value="" id=iptResult disabled=true>

    </body>

</HTML>

相 关 文 章
相 关 软 件
没有相关下载
逃生 放生 黄玫瑰 想太多 那滋味 擦肩而过 放手去爱 北京欢迎你 依然在一起 吻得太逼真 感动天感动地 坐上火车去拉萨 怎么会狠心伤害我
心碎 冲动 小太阳 别碰我 蒲公英 千山万水 改变自己 一定要爱你 等爱的玫瑰 陷入爱里面 北极星的眼泪 最后一次的温柔 亲爱的那不是爱情
光荣 火花 坏女人 日不落 樱花草 为你写诗 独家记忆 夏天的味道 寂寞才说爱 忘不掉的伤 爱上你是个错 第三者的第三者 地球人都知道我爱你
假如 相思 是非题 有缘人 舍不得 我的答铃 死而无憾 外滩十八号 越爱越难过 123木头人 和寂寞说分手 爱上你是我的错 爱情里没有谁对谁错
加入收藏留言建议自助友情链接普通友情链接站长的Blog
版权所有   COPYRIGHT 2002-2008 ★IT学习者★ ALL RIGHTS RESERVED.