复制代码 代码如下:
/******************************************************
// *功能描述:把密码输入控件写入页面中
// *参数说明:
// inputCtlName:原控件名
//
// 创建日期:2006-07-24
***************************************************** */
var InputControlAreaIndex=0;
var InputControlAreaPubKey='';
var InputControlAreaAccVer="115A7165-DE06-49B8-9850-15414C233E83:1009";
var InputControlAreaFlag="1";
var InputControlAreaAccVerFlag=false;
var InputControlAreaArray=new Array();
function InputControlArea(inputName,type){
//初始化控件标签
var input=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);
//取得有效控件
var returnObject=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='';
}
}else if(InputControlAreaFlag==2||InputControlAreaFlag==0)
{
input.onkeydown=null;
input.onchange=null;
input.onclick=null;
}
}
InputControlArea.prototype.init=function (inputCtlId,inputName){
//在函数末尾追加的控件,先调用。
function writeInputControl(clsid,id){
//生成控件标签
var classid="";
if(clsid!="")
{
classid=" classid='CLSID:"+clsid+"'";
}
inputSpan+='';
}
var inputSpan=document.all[inputName].outerHTML+"
";
writeInputControl("",inputCtlId);
//
var strCtls=InputControlAreaAccVer.split(",");
for(var i=0;i {
writeInputControl(strCtls[i].split(":")[0],inputCtlId);
//控件A
}
///////////////////////////////////////////////////////////////////////
inputSpan+='';
inputSpan+="
";
writeInputControl("",inputCtlId);
//
var strCtls=InputControlAreaAccVer.split(",");
for(var i=0;i
writeInputControl(strCtls[i].split(":")[0],inputCtlId);
//控件A
}
///////////////////////////////////////////////////////////////////////
inputSpan+='';
inputSpan+="
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 ;
}
var warning;
if(InputControlAreaAccVerFlag)
{
warning="您的密码输入控件版本无效,是否安装新版本?";
}
else
{
warning="您未安装密码输入控件,是否安装?";
}
var SetUpFlag=this.GetCookie("SetUpFlag");
var returnFlg=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";
}
}
//返回有效控件
return returnObj;
}
InputControlArea.prototype.getInputCtl=function (inputCtls,type){
var validSE=0;
for(var i=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;
return inputCtls[validSE];
}
function callOnBlurByName(inputCtlName){
document.all["Sec."+inputCtlName][InputControlAreaIndex].onblur.call();
}
InputControlArea.prototype.SetCookie=function (sName,sValue)
{
document.cookie=sName+"="+escape(sValue)+"; expires=Fri, 31 Dec 2999 23:59:59 GMT;";
}
// Retrieve the value of the cookie with the specified name.
InputControlArea.prototype.GetCookie=function GetCookie(sName)
{
// cookies are separated by semicolons
var aCookie=document.cookie.split(";");
for(var i=0;i
// a name/value pair (a crumb) is separated by an equal sign
var aCrumb=aCookie[i].split("=");
if(aCrumb[0].indexOf(sName)!=-1){
return unescape(aCrumb[1]);
}
}
// a cookie with the requested name does not exist
return null;
}
function initOnSubmit(){
for(var i=0;i
var submitHandler=document.forms[i].onsubmit;
if(submitHandler){
document.forms[i].onsubmit=function (){
initPassWord();
return submitHandler.call();
}
}
}
}
function initPassWord(){
for(var i=0;i
if(InputControlAreaArray[i]!=null&&InputControlAreaArray[i].onDoSubmit!=null)
{
InputControlAreaArray[i].onDoSubmit.call();
}
}
}
在线演示
打包文件下载