WEB开发网
开发学院网页设计JavaScript JavaScript 通用库(二) 阅读

JavaScript 通用库(二)

 2010-09-14 13:19:58 来源:WEB开发网   
核心提示: *///定义变量、设置默认值var LabelFontFace=“宋体,arial,Verdana“;var LabelFontColor=“#000000“;var LabelFontSize=“9pt“;var L

*/

//定义变量、设置默认值
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〉“;
    }
}

Tags:JavaScript 通用

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接