软键盘,copy自紫竹

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'MyJsp.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->


  </head>
  
  <body>
   <A title="软键盘" onClick="_softkeyboard_(document.getElementById('password'),window.top.document.getElementById('skb'));document.getElementById('password').focus();">软键盘</A>  
<DIV id=skb style="BORDER: #dbe1e6 1px solid; PADDING: 4px; DISPLAY: none;  Z-INDEX: 99; background-color:#F4FBFF; LEFT: 20px;  WIDTH: 500px;  POSITION: absolute; TOP: 35px; TEXT-ALIGN: center"></DIV>  
<input name="password" type="password" id="password" class="kinput"/>  
   
<SCRIPT type=text/javascript>   
    function _softkeyboard_(target,container){  
        var _ = _softkeyboard_;  
        _.target = target;  
        _.doc = container.ownerDocument;  
        (_.doc.parentWindow||_.doc.defaultView)._softkeyboard_ = _softkeyboard_;  
        _.skb = container;  
        _.skb.innerHTML = _.getkeyshtml();  
        var toggle = (_.skb.style.display == "block");  
        _.skb.style.display = toggle ? "none" : "block";  
        _.preventKey(target);  
        return toggle;  
    }  
   
    function closeKeyBoard()  
    {  
        document.getElementById('skb').style.display = "none";  
    }  
   
    _softkeyboard_.shifted = true;  
    _softkeyboard_.getkeyshtml = function(shifted){  
        var htm = [], keys = _softkeyboard_.shifted ?   
            ["`1234567890-=","backspace","<br/>"," ","qwertyuiop[]//","<br/>"," "," ","asdfghjkl;","'","<br/>","shift","zxcvbnm,./","shift"] :   
            ["~!@#$%^&*()_+","backspace","<br/>"," ","QWERTYUIOP{}|","<br/>"," "," ","ASDFGHJKL:",'"',"<br/>","shift","ZXCVBNM<>?","shift"];  
        var esp = {  
                "'":'<input type="button" value="\'" οnclick="_softkeyboard_.onkeydown(this);" />',  
                '"':"<input type='button' value='\"' οnclick='_softkeyboard_.onkeydown(this);' />",  
                "<br/>":"<br/>",  
                " ":" ",  
                "backspace":'<input type="button" value="<-" οnclick="_softkeyboard_.backspace();" />',  
                "shift":'<input type="button" style="width:50px;" value="shift" οnclick="_softkeyboard_.shifted=!_softkeyboard_.shifted;_softkeyboard_.skb.innerHTML = _softkeyboard_.getkeyshtml();" />'  
        };  
        for(var j = 0; j < keys.length; j++){  
            if(esp[keys[j]]){  
                htm.push(esp[keys[j]]);  
            }  
            else{  
                var x = new Date().getMilliseconds()%keys[j].length;  
                keys[j] =  keys[j].substr(x,keys[j].length) + keys[j].substr(0,x);  
                for(var i = 0; i < keys[j].length; i++){   
                    htm.push("<input type='button' class='key' value='"+ keys[j].charAt(i)+"' οnclick='_softkeyboard_.onkeydown(this);' />");  
                }  
            }  
        }  
        htm.push("<div style='margin-top:5px;' mce_style='margin-top:5px;'><input type='button' οnclick='closeKeyBoard()' value='确定' style='margin-right:20px;' mce_style='margin-right:20px;' /><input type='button' οnclick='closeKeyBoard()' value='关闭' /><div/>"); 
        return htm.join("");  
    }  
    _softkeyboard_.onkeydown = function(ele){  
        _softkeyboard_.target.value += ele.value;  
        _softkeyboard_.target.focus();  
    }  
    _softkeyboard_.backspace = function(){  
        with(_softkeyboard_.target){  
            value = value.substr(0,value.length-1);  
        }  
    }  
    _softkeyboard_.addCSSRule = function(key,value){}  
    _softkeyboard_.hide = function(){  
        if(_softkeyboard_.skb){  
            _softkeyboard_.skb.style.display = "none"  
        }  
    }  
    _softkeyboard_.preventKey = function(target){  
        var targetkeydown = function(e){  
            e = window.event?window.event:e;  
            switch(e.keyCode){  
                case 27://esc  
                case 9://tab  
                    _softkeyboard_.hide();  
                    if(window.event){e.returnValue = false;}else{e.preventDefault();}break;  
            }  
        };  
        //target.addEventListener ? target.addEventListener("keydown",targetkeydown,false) : target.attachEvent("onkeydown",targetkeydown);  
    }  
   
    window.top._softkeyboard_=_softkeyboard_;  
    _softkeyboard_.preventKey(window.top.document.body);  
   
</SCRIPT>   
  </body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值