简体   繁体   中英

prevent a default action with IE8

I have a script that on ONKEYDOWN event (eg Alt+f) it disables the default action that is to make browser to show its menu and make my custom action.

In IE8 event.returnValue does not do the job. I have also viewed that if I do alert(event.returnValue) the value is 'undefined' ad it seems as that property there isn't in the object but if I cycle the event object I found it.

Strange enough!

Maybe the browser access keys could not be disabled?

PS With Firefox all works! (with preventDefault() )

Although it is not possible to override behavior of "Ctrl+KEY" shortcuts (in IE), you can still override access keys. Use plain simple HTML for that.

<a href="javascript:;" accesskey="f"></a>

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM