English 中文(简体)
防止缺席事件行动不发挥作用......
原标题:Prevent default event action not working...?

我试图在我的网站上增加主要短机,使快速导航成为可能。 然而,由于我尝试了Alt +X,Im 陷入一个轻微的问题。 这项活动只进行罚款,并按原样转载<代码>false,但浏览器的卷宗号是无所不在的。 I ve还尝试了preventDefault方法,但没有改动。

文字的削减版是:

document.documentElement.onkeydown = function(e) {
    e = e || window.event;
    switch( e.keyCode || e.which) {
        // some cases here - most notably:
        case 116: // F5 key
            if( activeFrame) {
                activeFrame.contentWindow.location.reload();
                // reloads an iframe if one is active
                return false;
            }
            break;
        // more cases...
        case 88: // X key
            if( e.altKey) {
                // do something
                return false;
            }
    }
}

如上所述,压倒了F5关键工程的违约行动――浏览器只在没有机体的情况下重载该页。 我看不出如何防止菜单出现在Alt/kbd>+X

最佳回答

我实际上拥有一个网状,与CTRL短击钥匙一道工作,但随后决定I d为cl,并使用<条码>检索钥匙/代码>属性,并与IE一起处理这一具体问题。

The problem with going to CTRL shortcut keys is that many of those are more standard/useful across many applications (eg: cut, copy, paste, select all).

Ctrl+Alt相当安全,但需要用户方面做更多的工作。

我往往试图遵守《反恐法》,对《反恐法》进行 short击。

Demo of CTRL + A/CTRL + F being cancelled successfully: http://jsfiddle.net/egJyT/

问题回答




相关问题
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.

热门标签