首页

源码搜藏网

首页 > 网页特效 > jQuery特效 >

仿iphone软键盘输入文本框

创建时间:2014-06-24 19:01  

仿iphone软键盘输入文本框
仿iphone软键盘输入文本框
效果预览 立即下载

仿iphone软键盘输入文本框仿iphone软键盘输入文本框是一款基于jQuery+CSS3实现的仿制iphone类型软键盘特效。jQuery软键盘文本框iphone

 //模拟键盘事件,仅支持firefox,ie8-
    
    function simulateKeyEvent(target,keyCode)                         
    {         
        var customEvent = null;
        var a = typeof document.createEvent;


        if(typeof document.createEvent == "function"){//firefox
            try {
                customEvent = document.createEvent("KeyEvents");
                customEvent.initKeyEvent("keypress", true, true,window, false, false, false, false, keyCode, keyCode);     
                target.dispatchEvent(customEvent);
            } catch (ex){
                //console.log("This example is only demonstrating event simulation in firefox and IE.");        
            }
           


        } else if (document.createEventObject){ //IE
            customEvent = document.createEventObject();
            customEvent.bubbles = true;
            customEvent.cancelable = true;
            customEvent.view = window;
            customEvent.ctrlKey = false;
            customEvent.altKey = false;
            customEvent.shiftKey = false;
            customEvent.metaKey = false;
            customEvent.keyCode = keyCode;
            target.fireEvent("onkeypress", customEvent); 
                   
        } 
        else {
            //console.log("This example is only demonstrating event simulation in firefox and IE.");
        }
    }

上一篇:jquery+css3实现彩色时钟表
下一篇:jQuery+CSS3动画弹出框代码

相关内容

热门推荐