软键盘的实现

今天从CSDN上看到这段JS代码,感觉很不错,故收藏,拿出来供大家一起学习...
None.gif < script language = " javascript " >
None.gif
// more javascript from http://www.smallrain.net
None.gif
var  oPopUp = null ;
ExpandedBlockStart.gifContractedBlock.gif
function  SoftKeyboard(pwdObj) dot.gif {
InBlock.gifoPopUp
=window.createPopup();
InBlock.gif
var popBody=oPopUp.document.body;
InBlock.gifpopBody.style.backgroundColor 
= "#FFFF99";
InBlock.gifpopBody.style.border 
= "solid black 1px";
InBlock.gifWriteToPopup(oPopUp,pwdObj);
InBlock.gifoPopUp.show(
0,22,240,100,pwdObj);
ExpandedBlockEnd.gif}

ExpandedBlockStart.gifContractedBlock.gif
function  WriteToPopup(oPopUp,pwdObj) dot.gif {
InBlock.gif
var strHTML="<html><head>";
InBlock.gifstrHTML
+='<meta http-equiv="Content-Type" content="text/html; charset=gb2312">';
InBlock.gifstrHTML
+='<style type="text/css">';
ExpandedSubBlockStart.gifContractedSubBlock.gifstrHTML
+='.tddot.gif{text-align:center; background-color:#FFFF99; vertical-align:middle;font-size:13px;background-Image:(url:bg.gif); font-weight:800}';
ExpandedSubBlockStart.gifContractedSubBlock.gifstrHTML
+='.buttondot.gif{border:0;width:90%; height:95%;}';
InBlock.gifstrHTML
+='</style>';
InBlock.gifstrHTML
+='<script language="javascript">';
InBlock.gifstrHTML
+='var arrLow=new Array("`","1","2","3","4","5","6","7","8","9","0","-","=","\","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","[","]",";","\'",",",".","/","");';
InBlock.gifstrHTML
+='var arrUp =new Array("~","!","@","#","$","%","^","&","*","(",")","_","+","|","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","}",":","\\"","<",">","?",""); ';
InBlock.gifstrHTML+='var curOverTd=null; var curClkTd=null; var CapsStatus=
"black";';
InBlock.gifstrHTML+='var pwdObjectId=parent.document.getElementById(
"'+pwdObj.id+'");';
InBlock.gifstrHTML+='function TdMouseOver(TdObj){ ';
InBlock.gifstrHTML+='TdObj.style.backgroundColor=
"blue"; ';
InBlock.gifstrHTML+=' TdObj.style.color=
"white";';
InBlock.gifstrHTML+='curOverTd=TdObj;} ';
InBlock.gifstrHTML+='function TdMouseOut(TdObj){ ';
InBlock.gifstrHTML+='if(curClkTd==TdObj){ ';
InBlock.gifstrHTML+='TdObj.style.backgroundColor=
"red"; ';
InBlock.gifstrHTML+='TdObj.style.color=
"white"; ';
InBlock.gifstrHTML+='}else{ ';
InBlock.gifstrHTML+='TdObj.style.backgroundColor=
"#FFFF99"; ';
InBlock.gifstrHTML+='TdObj.style.color=
"black"; }';
InBlock.gifstrHTML+='} ';
InBlock.gifstrHTML+='function TdMouseClk(TdObj){ ';
InBlock.gifstrHTML+='if(curClkTd){ ';
InBlock.gifstrHTML+='curClkTd.style.backgroundColor=
"#FFFF99"; ';
InBlock.gifstrHTML+='curClkTd.style.color=
"black"; }';
InBlock.gifstrHTML+='TdObj.style.backgroundColor=
"red"; ';
InBlock.gifstrHTML+=' TdObj.style.color=
"white";';
InBlock.gifstrHTML+='curClkTd=TdObj; ';
InBlock.gifstrHTML+='curOverTd=null; ';
InBlock.gifstrHTML+='  pwdObjectId.value+=TdObj.innerText;';
InBlock.gifstrHTML+=' }';
InBlock.gifstrHTML+=' function btnCapsDown(btnObj){';
InBlock.gifstrHTML+='if(CapsStatus==
"black"){ CapsStatus="green"; ChgText(arrUp);}';
InBlock.gifstrHTML+='else{ CapsStatus=
"black"; ChgText(arrLow);}; ';
InBlock.gifstrHTML+='btnObj.style.color=CapsStatus==
"black"?"#000000":"#33FF66";';
InBlock.gifstrHTML+=' }';
InBlock.gifstrHTML+=' function ChgText(arr){';
InBlock.gifstrHTML+='var table=document.getElementById(
"tbKeyboard");';
InBlock.gifstrHTML+='for(var i=0;i<4;i++)';
InBlock.gifstrHTML+='for(var j=0;j<12;j++)';
InBlock.gifstrHTML+='table.rows[i].cells[j].innerText=arr[12*i+j];';
InBlock.gifstrHTML+=' }';
InBlock.gifstrHTML+=' function btnSpaceDown(){';
InBlock.gifstrHTML+='pwdObjectId.value+=
" "';
InBlock.gifstrHTML+=' }';
InBlock.gifstrHTML+=' function btnBackDown(){';
InBlock.gifstrHTML+='pwdObjectId.value=pwdObjectId.value.substring(0,pwdObjectId.value.length-1)';
InBlock.gifstrHTML+=' }';
InBlock.gifstrHTML+=' function btnEnterDown(){';
InBlock.gifstrHTML+='parent.oPopUp.hide();';
InBlock.gifstrHTML+=' }';
InBlock.gifstrHTML+='</scr'+'ipt></head> ';
InBlock.gifstrHTML+='<body bgcolor=
"#FFFFFF" style="margin:0; border:0;overflow:hidden;" οncοntextmenu="javascript:event.returnValue=false;" onselectstart="javascript:event.returnValue=false;"> ';
InBlock.gifstrHTML+='<table id=
"tbKeyboard" cellpadding="0" cellspacing="0" border="1" style="TABLE-LAYOUT: fixed; width:100%;height:100%; border-collapse:collapse; cursor:default" bordercolor="#111111">';
InBlock.gifvar arr=new Array(
"`","1","2","3","4","5","6","7","8","9","0","-","=","\\","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","[","]",";","\'",",",".","/","");
InBlock.giffor(var i=0;i<4;i++){
InBlock.gifstrHTML+='<tr height=
"12">';
InBlock.giffor(var j=0;j<12;j++)
InBlock.gifstrHTML+='<td class=
"td" valign="middle" onMouseOver="TdMouseOver(this)" onMouseOut="TdMouseOut(this)" onClick="TdMouseClk(this)">'+arr[i*12+j]+'</td>';
InBlock.gifstrHTML+='</tr
">';
ExpandedBlockEnd.gif}

None.gifstrHTML
+= ' < tr height = " 12 " >< td class = " td "  colspan = " 12 " >< table width = " 100% "   border = " 0 "  cellpadding = " 0 "  cellspacing = " 0 "  style = " margin:0 " > ';
None.gifstrHTML
+= ' < tr >< td class = " td "  width = " 20% "  valign = " middle " >< input type = " button "  value = " Shift "  style = " font-weight:800  "  onclick = " btnCapsDown(this) "  class = " button " ></ td > ';
None.gifstrHTML
+= ' < td class = " td "  width = " 35% "  valign = " middle " >< input type = " button "  value = " Space "  onclick = " btnSpaceDown() "  class = " button " ></ td > ';
None.gifstrHTML
+= ' < td class = " td "  width = " 25% "  valign = " middle " >< input type = " button "  value = " Back "  onclick = " btnBackDown() "  class = " button " ></ td > ';
None.gifstrHTML
+= ' < td class = " td "  width = " 20% "  valign = " middle " >< input type = " button "  value = " Enter "  onclick = " btnEnterDown() "  class = " button " ></ td > ';
None.gifstrHTML
+= ' </ tr ></ table ></ td > ';
None.gifstrHTML
+= ' </ tr ></ table ></ body ></ html > ';
None.gifoPopUp.document.write(strHTML);
None.gif}
None.gif
</ script >
None.gif
< input type = " text "  id = " txtPwd "  name = " txtPwd "  onclick = " SoftKeyboard(this) "  readonly = " readonly " >
None.gif

转载于:https://www.cnblogs.com/Lewis/archive/2006/07/14/451007.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值