我推荐您尝试提供键盘快捷键,但请注意,实现跨平台会有点痛苦。如果可行,我强烈建议在<a>
标签上使用access keys。我想accesskey
不会为你工作。我假设你读过the relevant YUI tutorial。
如果blur
和focus
是真正正确的道路要走,我会使用类似
YAHOO.util.Event.onDOMReady(init);
function init() {
// set up the keyboard listeners
setUpExceptionsToKeyboardShortcuts();
}
function disableShortcuts() {
// Do what you've got to do
}
function enableShortcuts() {
// Do what you've got to do
}
function setUpExceptionsToKeyboardShortcuts() {
var focusable = document.getElementsByTagName('input');
focusable = focusable.concat(document.getElementsByTagName('select'));
focusable = focusable.concat(document.getElementsByTagName('textarea'));
YAHOO.util.Event.addListener(focusable, 'focus', disableShortcuts);
YAHOO.util.Event.addListener(focusable, 'blur', ensableShortcuts);
}
访问键参考是伟大的,我完全忘了他们。不幸的是,他们对于这种情况不够好。 – user13200 2008-10-01 17:40:55