注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

樱之花

叶散的时候,你明白欢聚;花谢的时候,你明白青春.

 
 
 

日志

 
 
关于我

分类中“我的实验室”是我在日常工作中的一些知识总结,有些写的比较匆忙,可能大家在阅读时会产生困扰,后期有时间我会重新整理编辑,谢谢大家的到访,您们的支持是我前进的动力!

网易考拉推荐

JS模拟软键盘(javascript)  

2011-01-06 13:34:51|  分类: JS程式 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
<script language="javascript">
//more javascript from http://www.smallrain.net
var oPopUp=null;
function SoftKeyboard(pwdObj){
oPopUp=window.createPopup();
var popBody=oPopUp.document.body;
popBody.style.backgroundColor = "#FFFF99";
popBody.style.border = "solid black 1px";
WriteToPopup(oPopUp,pwdObj);
oPopUp.show(0,22,240,100,pwdObj);
}
function WriteToPopup(oPopUp,pwdObj){
var strHTML="<html><head>";
strHTML+='<meta http-equiv="Content-Type" content="text/html; charset=gb2312">';
strHTML+='<style type="text/css">';
strHTML+='.td{text-align:center; background-color:#FFFF99; vertical-align:middle;font-size:13px;background-Image:(url:bg.gif); font-weight:800}';
strHTML+='.button{border:0;width:90%; height:95%;}';
strHTML+='</style>';
strHTML+='<scr'+'ipt language="javascript">';
strHTML+='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","[","]",";","\'",",",".","/","");';
strHTML+='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","{","}",":","\\"","<",">","?",""); ';
strHTML+='var curOverTd=null; var curClkTd=null; var CapsStatus="black";';
strHTML+='var pwdObjectId=parent.document.getElementById("'+pwdObj.id+'");';
strHTML+='function TdMouseOver(TdObj){ ';
strHTML+='TdObj.style.backgroundColor="blue"; ';
strHTML+=' TdObj.style.color="white";';
strHTML+='curOverTd=TdObj;} ';
strHTML+='function TdMouseOut(TdObj){ ';
strHTML+='if(curClkTd==TdObj){ ';
strHTML+='TdObj.style.backgroundColor="red"; ';
strHTML+='TdObj.style.color="white"; ';
strHTML+='}else{ ';
strHTML+='TdObj.style.backgroundColor="#FFFF99"; ';
strHTML+='TdObj.style.color="black"; }';
strHTML+='} ';
strHTML+='function TdMouseClk(TdObj){ ';
strHTML+='if(curClkTd){ ';
strHTML+='curClkTd.style.backgroundColor="#FFFF99"; ';
strHTML+='curClkTd.style.color="black"; }';
strHTML+='TdObj.style.backgroundColor="red"; ';
strHTML+=' TdObj.style.color="white";';
strHTML+='curClkTd=TdObj; ';
strHTML+='curOverTd=null; ';
strHTML+='  pwdObjectId.value+=TdObj.innerText;';
strHTML+=' }';
strHTML+=' function btnCapsDown(btnObj){';
strHTML+='if(CapsStatus=="black"){ CapsStatus="green"; ChgText(arrUp);}';
strHTML+='else{ CapsStatus="black"; ChgText(arrLow);}; ';
strHTML+='btnObj.style.color=CapsStatus=="black"?"#000000":"#33FF66";';
strHTML+=' }';
strHTML+=' function ChgText(arr){';
strHTML+='var table=document.getElementById("tbKeyboard");';
strHTML+='for(var i=0;i<4;i++)';
strHTML+='for(var j=0;j<12;j++)';
strHTML+='table.rows[i].cells[j].innerText=arr[12*i+j];';
strHTML+=' }';
strHTML+=' function btnSpaceDown(){';
strHTML+='pwdObjectId.value+=" "';
strHTML+=' }';
strHTML+=' function btnBackDown(){';
strHTML+='pwdObjectId.value=pwdObjectId.value.substring(0,pwdObjectId.value.length-1)';
strHTML+=' }';
strHTML+=' function btnEnterDown(){';
strHTML+='parent.oPopUp.hide();';
strHTML+=' }';
strHTML+='</scr'+'ipt></head> ';
strHTML+='<body bgcolor="#FFFFFF" style="margin:0; border:0;overflow:hidden;" oncontextmenu="javascript:event.returnValue=false;" onselectstart="javascript:event.returnValue=false;"> ';
strHTML+='<table id="tbKeyboard" cellpadding="0" cellspacing="0" border="1" style="TABLE-LAYOUT: fixed; width:100%;height:100%; border-collapse:collapse; cursor:default" bordercolor="#111111">';
var 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","[","]",";","\'",",",".","/","");
for(var i=0;i<4;i++){
strHTML+='<tr height="12">';
for(var j=0;j<12;j++)
strHTML+='<td class="td" valign="middle" onMouseOver="TdMouseOver(this)" onMouseOut="TdMouseOut(this)" onClick="TdMouseClk(this)">'+arr[i*12+j]+'</td>';
strHTML+='</tr">';
}
strHTML+='<tr height="12"><td class="td" colspan="12"><table width="100%"  border="0" cellpadding="0" cellspacing="0" style="margin:0">';
strHTML+='<tr><td class="td" width="20%" valign="middle"><input type="button" value="Shift" style="font-weight:800 " onclick="btnCapsDown(this)" class="button"></td>';
strHTML+='<td class="td" width="35%" valign="middle"><input type="button" value="Space" onclick="btnSpaceDown()" class="button"></td>';
strHTML+='<td class="td" width="25%" valign="middle"><input type="button" value="Back" onclick="btnBackDown()" class="button"></td>';
strHTML+='<td class="td" width="20%" valign="middle"><input type="button" value="Enter" onclick="btnEnterDown()" class="button"></td>';
strHTML+='</tr></table></td>';
strHTML+='</tr></table></body></html>';
oPopUp.document.write(strHTML);
}
</script>
<input type="text" id="txtPwd" name="txtPwd" onclick="SoftKeyboard(this)" readonly="readonly">
  评论这张
 
阅读(1775)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017