发一个 Demo

bhtfg538 bhtfg538 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
散分:
今天 国人都要散分 为奥运加油

随便封的一个 js 小键盘

xxx.js
var Class=
{
Create:function()
{
return function()
{
this.Initialize.apply(this, arguments);//调用构造函数
}
}
};
Object.extend = function(destination, source) {
for (var property in source) {
destination[property] = source[property];//实现继承
}
return destination;
};
var $=function(id)
{
return "string"==typeof(id)?document.getElementById(id):id;
};
var Browser=
{
IE:/MSIE/.test(window.navigator.userAgent),
FireFox:/Firefox/.test(window.navigator.userAgent)
};
var Drag=Class.Create();
Drag.prototype=
{
Initialize: function(obj, drag) {
var oThis = this;
this._obj = $(obj);//拖放对象
this.Drag = $(drag);//触发对象
this._x = this._y = 0;//记录鼠标相对拖放对象的位置
this._fM = function(e){ oThis.Move(window.event || e); }//移动事件
this._fS = function(){ oThis.Stop(); }//停止事件
this._obj.style.position = "absolute";
this.AddEvent(this.Drag, "mousedown", function(e){ oThis.Start(window.event || e); }); //初始化Start获得鼠标焦点事件
},
AddEvent:function(oTarget, sEventType, fnHandler)
{
if (Browser.FireFox)
{
oTarget.addEventListener(sEventType, fnHandler, false);//FF
}
else if (Browser.IE)
{
oTarget.attachEvent("on" + sEventType, fnHandler);//IE 6+
}
else
{
oTarget["on" + sEventType] = fnHandler;//IE5-
}
},
DelEvent:function(oTarget, sEventType, fnHandler) {
if (Browser.FireFox)
{
oTarget.removeEventListener(sEventType, fnHandler, false); //FF
}
else if (Browser.IE)
{
oTarget.detachEvent("on" + sEventType, fnHandler); //IE 6+
}
else
{
oTarget["on" + sEventType] = null;//IE5-
}
},
Start:function(oEvent) {
if(Browser.FireFox){
window.getSelection().removeAllRanges();}
else
{
document.selection.empty();
}
//记录鼠标相对拖放对象的位置
this._x = oEvent.clientX - this._obj.offsetLeft;
this._y = oEvent.clientY - this._obj.offsetTop;
//mousemove时移动 mouseup时停止
this.AddEvent(document, "mousemove", this._fM);
this.AddEvent(document, "mouseup", this._fS);
//使鼠标移到窗口外也能释放
if(Browser.IE)
{
this.AddEvent(this.Drag, "losecapture", this._fS);//失去焦点时候出发Stop事件
this.Drag.setCapture();//重新获得焦点 初始化Drag 然后获得焦点
}
else
{
this.AddEvent(window, "blur", this._fS);//FF 就是 blur 事件
}
},
Move:function(oEvent) {



//当前鼠标位置减去相对拖放对象的位置得到offset位置
var iLeft = oEvent.clientX - this._x, iTop = oEvent.clientY - this._y;
this._obj.style.left = iLeft + "px";
this._obj.style.top = iTop + "px";
},
Stop:function() {
//移除事件
this.DelEvent(document, "mousemove", this._fM);
this.DelEvent(document, "mouseup", this._fS);
if(Browser.IE)
{
this.DelEvent(this.Drag, "losecapture", this._fS);
this.Drag.releaseCapture();
}
else
{
this.DelEvent(window, "blur", this._fS);
}
}
};
Array.prototype.Del=function(n)
{
if(n<0)
return this;
else
return this.slice(0,n).concat(this.slice(n+1,this.length));
};
var KeyBoard=Class.Create();
KeyBoard.prototype=
{
Initialize:function(obj,id,type)
{
var Othis=this;
this._type=type;//键盘类型
this._id=id;//给哪个id 获取值
this._obj=$(obj);//显示在在哪个div id下
this._obj.innerHTML="";
this._objid=obj;
this.arr=['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','0','1','2','3','4','5','6','7','8','9'];
this.GetCode(this.arr,this._type);
},
GetCode:function(arr,type)
{
var oThis=this;
var obj=document.createElement("table");
obj.width="200";
obj.height="100";
obj.cellpadding="4";
obj.bgColor="#deeefe";
var rowtitle=obj.insertRow();
rowtitle.align="right";
rowtitle.bgColor="#83bdf9";
rowtitle.height="26";
var celltitle=rowtitle.insertCell();
celltitle.innerHTML="<div onclick=document.getElementById('"+this._objid+"').style.display='none'><a href='#' style='color:red;font-size:14px; text-decoration:none'>关闭</a></div>"
celltitle.colSpan="6";
for(var j=0;j<6;j++){
var row=obj.insertRow();
row.align="center";
for(var i=0;i<6;i++)
{
var index = Math.floor(Math.random()*(arr.length-1));
var cell=row.insertCell();
divid="s"+index;
var divvalue;
if(type=="upper")
{
divvalue=arr[index].toLocaleUpperCase();
}
else if(type="lower")
{
divvalue=arr[index];
}
else
{
divvalue=arr[index];
}
cell.innerHTML="<div id='"+divid+"' onmouseover=this.style.background='#aabffb' onmouseout=this.style.background='' onclick=\"document.getElementById('"+this._id+"').value+='"+divvalue+"';\" style='border:1px solid #0d5096; width:28px; height:17px;cursor:hand;'><font style='color:#0b33b5;font-weight:bold;font-size:15px;'>"+divvalue+"</div>";
arr=arr.Del(index);
}
}
var rowend=obj.insertRow();
rowend.align="center";
var cellend=rowend.insertCell();
cellend.colSpan="2";
cellend.innerHTML="<div onmouseover=this.style.background='#aabffb' onmouseout=this.style.background='' style='border:1px solid #0d5096; height:17px;cursor:hand;' onclick=document.getElementById('"+this._id+"').value=document.getElementById('"+this._id+"').value.slice(0,-1);><font style='color:#0b33b5;font-weight:bold;font-size:15px;'>退格</font></div>";
var cellend=rowend.insertCell();
cellend.colSpan="2";
cellend.innerHTML="<div onmouseover=this.style.background='#aabffb' onmouseout=this.style.background='' style='border:1px solid #0d5096; height:17px;cursor:hand;' onclick=\"new KeyBoard('"+this._objid+"','"+this._id+"','upper')\";><font style='color:#0b33b5;font-weight:bold;font-size:15px;'>大写</font></div>";
var cellend=rowend.insertCell();
cellend.colSpan="2";
cellend.innerHTML="<div onmouseover=this.style.background='#aabffb' onmouseout=this.style.background='' style='border:1px solid #0d5096; height:17px;cursor:hand;' onclick=\"new KeyBoard('"+this._objid+"','"+this._id+"','lower')\"><font style='color:#0b33b5;font-weight:bold;font-size:15px;'>小写</font></div>";
this._obj.appendChild(obj);
}
};

xxx.aspx 自己修改成xxx.htm 或者 .asp
<script type="text/javascript" src="lf/Login.js"></script></head><body><form id="form1" runat="server"><div>
<table align="center" cellpadding="0" cellspacing="0">
<tr align="center">
<td height="200"><strong>登录系统</strong></td>
</tr>
<tr>
<td>管理员帐号:<asp:TextBox runat="server" ID="tb_ServerUserName" ToolTip="管理员帐号"></asp:TextBox></td>
<td></td>
</tr>
<tr>
<td>管理员密码:<asp:TextBox runat="server" ID="tb_ServerUserPassword" TextMode="Password" ToolTip="管理员密码"></asp:TextBox><img src="../images/KeyBoard.GIF" alt="软键盘" onclick="document.getElementById('s1').style.display='block';"/></td><td><div id="s1" style="display:none;"></div></td>
</tr>
<tr>
<td>系统验证码:<asp:Image runat="server" ID="img_ServerSafeCode" ToolTip="系统验证码"/>
</td>
</tr>
<tr align="center">
<td><asp:Button ID="btn_ServerLogin" runat="server" Text="登入管理"/>  
<input type="reset" value="重新填写"/>
</td><td></td>
</tr>
</table>
</div></form>
<script type="text/javascript">
new Drag("s1","s1");
new KeyBoard("s1","tb_ServerUserPassword","lower");
document.getElementById("tb_ServerUserPassword").onkeyup=function(str)
{
return function()
{
this.value="";
alert("为了您的账户安全,请使用小键盘!");
}
}();
</script>

</body>

键盘 暂时不支持 ff
拖动支持 讨厌 ff insertRow 还要加 insertRow(0) 和tbody
烦~
呵呵~
献丑了


...全文

相关推荐

一个简单的手机重启的功能我们在有些应用里面需要重启手机这里发一个手机重启的小demo.rar

一个简单的手机重启的功能我们在有些应用里面需要重启手机这里发一个手机重启的小demo.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。

weixin_39840914

IOS应用源码Demo-发一个模拟扑克 开局和出牌的动画效果 pocker_forTest-毕设学习.zip

前两年IOS应用源码-主要是用于毕业设计学习的。

芝麻粒儿

发色检测DEMO

分享一个发色检测DEMO,效果很不错!采用C#编程实现,完整可运行!

Trent1985

二维码登录demo

包含两个文件:一个是显示二维码,请求服务端推送登录token的demo,主要实现websocket请求,有源码。 另外一个是模拟手机扫码的demo,因为只是一个网络请求,就不传源码了。有需要的朋友可以发站内信找我索要。 服务端亲测可用

wangyuetingtao

Dubbo入门---搭建一个最简单的Demo框架

Dubbo开始于电商系统,因此在这里先从电商系统的演变讲起。1.单一应用框架(ORM) 当网站流量很小时,只需一个应用,将所有功能如下单支付等都部署在一起,以减少部署节点和成本。缺点:单一的系统架构,使得在开发过程中,占用的资源越来越多,而且随着流量的增加越来越难以维护2.垂直应用框架(MVC) 垂直应用架构解决了单一应用架构所面临的扩容问题,流量能够分散到各个子系统当中,且系统的体积可控,一定程度上降低了开发人员之间协同以及维护的成本,提升了开发效率。

weixin_38557068
评论 24
收藏 已收藏
分享
返回顶部
bhtfg538
JavaScript 87,984 成员 224,681 内容