发一个 Demo

bhtfg538 2008-08-08 09:40:55
散分:
今天 国人都要散分 为奥运加油

随便封的一个 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
烦~
呵呵~
献丑了


...全文
200 24 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
接分灌水
bhtfg538 2008-08-08
  • 打赏
  • 举报
回复
今天把论坛全部水了
loveyunwt 2008-08-08
  • 打赏
  • 举报
回复
大家今天要玩开心哈

lzp19864 2008-08-08
  • 打赏
  • 举报
回复
支持散分
bhtfg538 2008-08-08
  • 打赏
  • 举报
回复
散分了
大家今天要玩开心哈
sxn19811006 2008-08-08
  • 打赏
  • 举报
回复
gao shou
mingxuan3000 2008-08-08
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 bhtfg538 的回复:]
举国同庆~
[/Quote]
bhtfg538 2008-08-08
  • 打赏
  • 举报
回复
呵呵 Up
beeqee 2008-08-08
  • 打赏
  • 举报
回复
好。接分。。
ice241018 2008-08-08
  • 打赏
  • 举报
回复
接分
orz_ORZ_orz 2008-08-08
  • 打赏
  • 举报
回复
学习并庆祝
loveyunwt 2008-08-08
  • 打赏
  • 举报
回复
举国同庆~
bhtfg538 2008-08-08
  • 打赏
  • 举报
回复
呵呵 Up
huwei12345 2008-08-08
  • 打赏
  • 举报
回复
接分啊,哈哈
庆祝下……
bhtfg538 2008-08-08
  • 打赏
  • 举报
回复
UP一下下
bhtfg538 2008-08-08
  • 打赏
  • 举报
回复
举国同庆~
s_liangchao1s 2008-08-08
  • 打赏
  • 举报
回复
jf
bhtfg538 2008-08-08
  • 打赏
  • 举报
回复
呵呵 接分了啊
快来哦

大家给点意见哈
softforce 2008-08-08
  • 打赏
  • 举报
回复
欣赏一下~~~
amandag 2008-08-08
  • 打赏
  • 举报
回复
up
加载更多回复(4)
项目名称:[精仿]360安全卫士-10.30更新(CSkin Demo) 界面库版本号:10.30 最新版本 下载内容: 精仿360安全卫士源码一份, 可引用至工具箱最新版CSkin.dll一份 实现功能: 1.光标题。 2.直角边框和阴影。 3.360安全卫士主界面模仿。 4.多系统支持,不需要win8系统,即可实现win8风格的360。 5.自定义控件的美化使用。 界面库更新文档: CC2013-10.30 1.由于SkinForm名字太多人使用,界面库命名正式改为CSkin.dll,官网www.cskin.net。 2.SkinTabControl标签中添加菜单箭头,可点击展开菜单。 3.SkinTabControl添加标签关闭按钮。 4.修复部分中文乱码问题。 5.优化好友列表右键菜单。 6.将窗体自定义系统按钮改为集合模式,可添加无数个自定义系统按钮。自定义系统按钮事件中可以 e.参数 来判断。 7.增加360安全卫士-DEMO案例。 8.增加SkinAnimatorImg控件,用于支持位图动画的播放。如360的动态logo。 9.各种细节BUG优化。 CC2013-10.11 1.添加SkinTabControlEx,加入更加自定义的美化属性和动画效果。 2.添加SkinAnimator,通用动画控件。 3.添加Html编辑器控件 4.修复SkinButton图标和文本相对位置的BUG CC2013-9.26 1.优化好友列表CPU占用 2.好友列表加入好友登录平台属性:安卓 苹果 WEBQQ PC 3.优化标题绘制模式,新添标题绘制模式属性。 4.新添标题偏移度属性。 5.加入圆形进度条控件:ProgressIndicator。 CC2013-9.5.2 1.优化截图控件,截图工具栏加入新功能。 2.解决个人信息卡和天气窗体显示后不会消失的问题。 3.各种细节BUG优化。 CC2013-9.5.1 1.解决贴边左右隐藏的BUG。 2.解决窗体点击事件不能触的问题。 3.优化SkinButton继承父容器背景色的代码。 4.解决SkinButton异常错误。 CC2013-9.3 1.好友列表右键菜单没反应问题。 2.新增美化控件SkinDatagridview。 3.密码软件盘回删不了文字问题。 4.双击窗体最大化,最大化后再双击恢复原大小,(win7)。 5.部分细节调优。 小编:下载不要分,DEMO教你如何熟练使用CSkin界面库美化自己的窗体。 友情链接: http://bbs.csdn.net/topics/390510544 (精仿QQ2013局域通讯) http://download.csdn.net/detail/lyx_520/5710799 (C#实现Win8窗体)

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧