日期:2013-02-12  浏览次数:20977 次

1、
<HTML>
<HEAD>
<PUBLIC>
<COMPONENT TAGNAME="COMBOBOX">
<PROPERTY NAME="Text" GET="get_Text" PUT="put_Text">
<PROPERTY NAME="Width" GET="get_Width" PUT="put_Width">
<METHOD NAME="SetFocus" INTERNALNAME="htcFocus">
<METHOD NAME="AddItems" INTERNALNAME="htcAddItems">
<EVENT NAME="onYYCenter" ID="idEnter">
<EVENT NAME="onYYCChoose" ID="idChoose">
<ATTACH EVENT="oncontentready" ONEVENT="htcInit()">
</COMPONENT>
</PUBLIC>
<SCRIPT LANGUAGE="javascript">
function htcInit()
{
defaults.viewLink=document;
defaults.viewInheritStyle=false;
Body_Init();
}
function htcAddItems(items)
{
var i,len;
len=pCombo.options.length;
for(i=0;i<len;i++)
{pCombo.remove(0);}
for(i=0;i<items.length;i++)
{
var o;
if((typeof items[i])=='string')
{
if(!HasTheValue(items,i))
{
o=document.createElement('OPTION');
o.text=items[i];
pCombo.add(o);
}
}
}
}
function htcFocus()
{
pText.focus();
}
function get_Text()
{
return pText.value;
}
function put_Text(Value)
{
pText.value=Value;
}
function get_Width()
{
return pCombo.style.width;
}
function put_Width(Value)
{
pCombo.style.width=Value;
}
</SCRIPT>

<SCRIPT LANGUAGE="javascript">
function Body_Init()
{
var iRight=pCombo.clientWidth;
var iBottom=pCombo.clientHeight;
var iLeft=(pCombo.clientWidth-18);
pCombo.style.clip='rect(0,'+iRight+','+iBottom+','+iLeft+')';
pText.style.width=(pCombo.clientWidth);
pText.style.height=(pCombo.clientHeight);
pText.style.top=0;
pText.style.left=0;
}
function Combo_Select()
{
pText.value=pCombo.options[pCombo.selectedIndex].text;
}
function Text_ChkKey()
{
if(event.keyCode==13)
{
idEnter.fire();
}
}
function HasTheValue(sitems,i)
{
var ii;
for(ii=0;ii<i;ii++)
{
if(sitems[ii]==sitems[i])
return true;
}
return false;
}
</SCRIPT>
</HEAD>
<BODY>
<SELECT STYLE="position:absolute;left:0;top:0;" ONCHANGE="Combo_Select()" NAME="pCombo">
</SELECT>
<INPUT STYLE="position:absolute;left:0;top:0;z-index:4000" onKeyPress="Text_ChkKey()" TYPE="TEXT" NAME="pText">
</BODY>
</HTML>

2、
function getLeftPostion( theObj )
{
var pos = 0;
while ( theObj != null )
{
pos += theObj.offsetLeft;
//get the Object which contain theObj.
theObj = theObj.offsetParent;
}
return pos;
}
function getTopPostion( theObj )
{
var pos = 0;
while ( theObj != null )
{
pos += theObj.offsetTop;
//get the Object which contain theObj.
theObj = theObj.offsetParent;
}
return pos;
}
function checkVersion()
{
var isBadVersion=true;
var curVer=navigator.appVersion;
var pos=parseInt(curVer.indexOf("MSIE"));
if (pos>=1)
{
var intVer=parseInt(curVer.charAt(pos+5));
if (intVer>=5)
{ isBadVersion=false;}
}
if (isBadVersion)
{
var msg="This page may not be displayed properly:\n"+
" This product requires Microsoft Internet Explorer 5 or later browser only.";