English 中文(简体)
在 Javascript 中创建密钥晚上
原标题:Create KeyEvent in Javascript

我遇到了以下的问题- 我正抓住一个关键事件, 我需要创建一个新的更改的关键事件( 因为密钥 Code 属性似乎只读), 然后再处理新建的 KeyEvent 。 我在 StackOverplow 遇到一些旧的岗位, 处理类似的情况, 但是:

  • 我需要这个在Webkit下工作 /在StackOverfow这里有个解决方案 但是它只在Gecko工作

  • 我需要另设一个密钥 Event, 而不是TextInputEvent, 因为“ TextInputEvent” 只会让我指定一个要插入的字符串, 而我不能这样做, 因为我使用第三方工具来处理这个事件, 我需要一个密钥代码 。

  • 我尝试了 jQuery #trigger () () () 但它对我行不通。 我的代码如下:

    var event = jQuery.event( keydown );
    event.which = 13; //I m trying to simulate an enter
    $( iframe ).contents().find( document ).find( body ).trigger(event); //my content is inside an iframe
    
最佳回答
(function($){
    $(window).load(function(){

        var e = $.Event("keydown");
        e.which = 13;
        e.keyCode = 13;
        $( iframe ).contents().find( html, body ).trigger(e);

    });
})(jQuery);
问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签