文本版|topic 高级搜索
   名人堂 帮助 论坛制度 意见反馈 | 首页 博客 周新贴 招聘 专题 新闻
RSS 底部
 
社区导航: 专家门诊   网络技术   操作系统   数据库   程序设计   系统应用   考试认证   CIO及信息化   站长交流   综合交流   下载基地  51CTO产品服务 设为首页 | 收藏本站
51CTO技术论坛» 技术白皮书 » WEB » JavaScript 通用库(二)       [ 打印]  [ 订阅]  [ 收藏]  [ 推荐给朋友]   [ 本帖文本页]

论坛跳转:
     
标题: JavaScript 通用库(二)  ( 查看:5437  回复:4 )   
 
danni505
主版主  点击可查看详细


帖子 1490
精华 7
无忧币 8609
积分 6767
阅读权限 150
来自 (保密)
注册日期 2006-5-1
最后登录 2008-5-8 离线

[查看资料]  [发短消息]  [Blog
[个人主页]    QQ    ICQ 状态     
发表于:2006-8-20 18:38   标题:JavaScript 通用库(二)
上一帖 |
/*
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+=“ “+str+“ “;
    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=\“javascriptoSomeThing(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〉



『 天道酬勤 』      君子之行,静以修身,俭以养德。非淡泊无以明志,非宁静无以致远。

2006-8-20 18:381楼
[ 顶部 ]
 
计算机客
副版主  点击可查看详细


处女座  
帖子 2099
精华 3
无忧币 5595
积分 3675
阅读权限 140
来自 (保密)
注册日期 2006-9-24
最后登录 2008-5-12 离线

[查看资料]  [发短消息]  [Blog
[个人主页]    QQ       
发表于:2006-11-1 13:32 
UP



技术不是一辈子,管理不是每一个人都可以,Come On 2008 改变自己!!!
2006-11-1 13:322楼
[ 顶部 ]
 
kqq1985
新新人类  点击可查看详细



帖子 4
精华 0
无忧币 23
积分 14
阅读权限 20
注册日期 2006-11-24
最后登录 2007-9-25 离线

[查看资料]  [发短消息]  [Blog
       
发表于:2006-11-24 12:56 
好东西拉
顶顶
2006-11-24 12:563楼
[ 顶部 ]
 
haj_21
新新人类  点击可查看详细



帖子 3
精华 0
无忧币 13
积分 13
阅读权限 20
注册日期 2006-11-23
最后登录 2008-2-24 离线

[查看资料]  [发短消息]  [Blog
       
发表于:2007-1-24 05:12 
ding



千里之外,传递你对震灾人民的关怀
2007-1-24 05:124楼
[ 顶部 ]
 
vagal.c
技术员  点击可查看详细


十二生肖之鸡   天秤座   行业勋章   技术勋章   诚信兄弟  
帖子 246
精华 0
无忧币 251
积分 246
阅读权限 30
注册日期 2007-9-16
最后登录 2008-5-17 在线

[查看资料]  [发短消息]  [Blog
  QQ       
发表于:2007-9-27 13:39 
good



千里之外,传递你对震灾人民的关怀
2007-9-27 13:395楼
[ 顶部 ]
     
论坛跳转:  

| | |

| | |

| | |

标记已读 · 删除论坛Cookies · 文本版 · WAP
 
| 诚征版主 | 版主堂 | 意见建议 | 大史记 | 论坛地图
Copyright©2005-2008 51CTO.COM  Powered by Discuz!
本论坛言论纯属发布者个人意见,不代表51CTO网站立场!如有疑义,请与管理员联系。
京ICP备05051492号