复制代码 代码如下:
/******************************************************
//*功能描述:把密码输入控件写入页面中
//*参数说明:
//inputCtlName:原控件名
//
//创建日期:2006-07-24
******************************************************/
varInputControlAreaIndex=0;
varInputControlAreaPubKey='';
varInputControlAreaAccVer="115A7165-DE06-49B8-9850-15414C233E83:1009";
varInputControlAreaFlag="1";
varInputControlAreaAccVerFlag=false;
varInputControlAreaArray=newArray();
functionInputControlArea(inputName,type){
//初始化控件标签
varinput=document.all[inputName];
//初始化软键盘
//this.initKeyBoard(input);
//判断控件是否启用
if(input==null||arguments.length!=2||(InputControlAreaFlag!=2&&InputControlAreaFlag!=3)){
this.obj=false;
return;
}
//生成控件标签
this.init("Sec."+inputName,inputName);
//取得有效控件
varreturnObject=this.getInputCtl(document.all["Sec."+inputName],type);
//显示有效控件
this.obj=this.displayInput(returnObject,document.all[inputName]);
InputControlAreaArray[InputControlAreaArray.length]=this.obj;
}
InputControlArea.prototype.initKeyBoard=function(input){
if(InputControlAreaFlag==3||InputControlAreaFlag==1)
{
input.onkeydown=function(){
Calc.password.value=this.value;
}
input.onchange=function(){
Calc.password.value=this.value;
}
input.onclick=function(){
password1=this;
showkeyboard();
this.readOnly=1;
Calc.password.value='';
}
}elseif(InputControlAreaFlag==2||InputControlAreaFlag==0)
{
input.onkeydown=null;
input.onchange=null;
input.onclick=null;
}
}
InputControlArea.prototype.init=function(inputCtlId,inputName){
//在函数末尾追加的控件,先调用。
functionwriteInputControl(clsid,id){
//生成控件标签
varclassid="";
if(clsid!="")
{
classid="classid='CLSID:"+clsid+"'";
}
inputSpan+='<OBJECT'+classid+'id='+id+'VIEWASTEXTstyle="display:none"size="20"width="100"height="17">'+'</OBJECT>';
}
varinputSpan=document.all[inputName].outerHTML+"<divid='"+inputName+"Area'style='border:1pxsolid#69c;padding:0;vertical-align:top;width:148;height=17;display:none'>";
writeInputControl("",inputCtlId);
//
varstrCtls=InputControlAreaAccVer.split(",");
for(vari=0;i<strCtls.length;++i)
{
writeInputControl(strCtls[i].split(":")[0],inputCtlId);
//控件A
}
///////////////////////////////////////////////////////////////////////
inputSpan+='<imgid='+inputCtlId+"img"+'SRC="images/icon_small_hand.gif"ALT="已使用密码输入控件,方便您的密码输入!"width=16height=17style="vertical-align:top;display:none"></img>';
inputSpan+="</div>";
document.all[inputName].outerHTML=inputSpan;
}
InputControlArea.prototype.displayInput=function(returnObj,input){
//控件有效
if(returnObj.classid!="")
{
input.style.display="none";
returnObj.style.display="";
document.all[returnObj.id+"img"].style.display="";
document.all[input.name+"Area"].style.display="inline";
returnObj.onblur=function(){
//判断离开焦点时的处理是否存在
if(input.onblur)
{
input.onblur.call();
}
//设置密码
//input.value=returnObj.GetPassword(InputControlAreaPubKey);
//returnObj.length=returnObj.GetLength();
}
returnObj.onDoSubmit=function(){
input.value=returnObj.GetPassword(InputControlAreaPubKey);
returnObj.length=returnObj.GetLength();
}
if(InputControlAreaPubKey=='')
{
initOnSubmit();
InputControlAreaPubKey=returnObj.GetPubKey(InputControlAreaPubKey);
}
returnObj.SetFunName(input.name);
}else{
//控件无效
input.style.display="";
returnObj=false;
if((window.location.toString()).indexOf("LOGIN")==-1)
{
return;
}
varwarning;
if(InputControlAreaAccVerFlag)
{
warning="您的密码输入控件版本无效,是否安装新版本?";
}
else
{
warning="您未安装密码输入控件,是否安装?";
}
varSetUpFlag=this.GetCookie("SetUpFlag");
varreturnFlg=this.GetCookie("returnFlg");
if(returnFlg=="1")
{
this.SetCookie("returnFlg","0");
return;
}
if(SetUpFlag!="0"||SetUpFlag==null)
{
this.SetCookie("SetUpFlag","1");
top.location="/app/B2CMainPlatV5?CCB_IBSVersion=V5&CUSTYPE=0&TXCODE=801002";
}
}
//返回有效控件
returnreturnObj;
}
InputControlArea.prototype.getInputCtl=function(inputCtls,type){
varvalidSE=0;
for(vari=inputCtls.length-1;i>=1;i--){
try{
if(InputControlAreaAccVer.indexOf(inputCtls[i].GetVersion())==-1){
InputControlAreaAccVerFlag=true;
continue;
}
inputCtls[i].SetCryptFlag(type);
validSE=i;
break;
}catch(e){
//continue;
}
try{
inputCtls[i].GetStrMsg();
validSE=i;
break;
}catch(e){
continue;
}
}
InputControlAreaIndex=validSE;
returninputCtls[validSE];
}
functioncallOnBlurByName(inputCtlName){
document.all["Sec."+inputCtlName][InputControlAreaIndex].onblur.call();
}
InputControlArea.prototype.SetCookie=function(sName,sValue)
{
document.cookie=sName+"="+escape(sValue)+";expires=Fri,31Dec299923:59:59GMT;";
}
//Retrievethevalueofthecookiewiththespecifiedname.
InputControlArea.prototype.GetCookie=functionGetCookie(sName)
{
//cookiesareseparatedbysemicolons
varaCookie=document.cookie.split(";");
for(vari=0;i<aCookie.length;i++)
{
//aname/valuepair(acrumb)isseparatedbyanequalsign
varaCrumb=aCookie[i].split("=");
if(aCrumb[0].indexOf(sName)!=-1){
returnunescape(aCrumb[1]);
}
}
//acookiewiththerequestednamedoesnotexist
returnnull;
}
functioninitOnSubmit(){
for(vari=0;i<document.forms.length;i++){
varsubmitHandler=document.forms[i].onsubmit;
if(submitHandler){
document.forms[i].onsubmit=function(){
initPassWord();
returnsubmitHandler.call();
}
}
}
}
functioninitPassWord(){
for(vari=0;i<InputControlAreaArray.length;i++){
if(InputControlAreaArray[i]!=null&&InputControlAreaArray[i].onDoSubmit!=null)
{
InputControlAreaArray[i].onDoSubmit.call();
}
}
}
在线演示
打包文件下载