We're calling on all EU-based Mozillians with iOS or iPadOS devices to help us monitor Apple’s new browser choice screens. Join the effort to hold Big Tech to account!

본 사이트는 여러분의 사용자 경험을 개선하기 위해 유지 보수를 진행하는 동안 기능이 제한됩니다. 도움말로 문제가 해결되지 않고 질문을 하고 싶다면 Twitter의 @FirefoxSupport 및 Reddit의 /r/firefox 채널을 활용하세요.

Mozilla 도움말 검색

고객 지원 사기를 피하세요. 저희는 여러분께 절대로 전화를 걸거나 문자를 보내거나 개인 정보를 공유하도록 요청하지 않습니다. "악용 사례 신고"옵션을 사용하여 의심스러운 활동을 신고해 주세요.

자세히 살펴보기

Our AJAX app intercepts F9 to provide context sensitive help. It works in IE7+, Chrome, Safari and Opera, but not in Firefox. Help!

  • 4 답장
  • 2 이 문제를 만남
  • 2 보기
  • 최종 답변자: lrirwin

more options

We researched IE, Firefox, Chrome, Safari and Opera - looking for a common function key that was unused to utilize for our app's context help key - and settled on the F9 key. Is there a way to ensure that the F9 key-press can be passed to the page -- it appears to do nothing in Firefox, but is not passed to the page. -- Thanks!

We researched IE, Firefox, Chrome, Safari and Opera - looking for a common function key that was unused to utilize for our app's context help key - and settled on the F9 key. Is there a way to ensure that the F9 key-press can be passed to the page -- it appears to do nothing in Firefox, but is not passed to the page. -- Thanks!

선택된 해결법

Firefox does not populate window.event like IE does. It never has. Modern browsers can pass the event object from the inline handler. Here's an example. I don't know whether older browsers support this (it works in IE8):

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Test F9 keydown inline handler</title>
</head>
<body>
<p>Try F9<br><input type="text" name="textinput" size="25" value="sample value" onkeydown="keys(event,100)"></p>
<script type="text/javascript">
function keys(evt, arg){
  if (evt.which == 120 || evt.keyCode == 120){ // F9 key
    alert("Function passed: "+arg);
  }
  return false;
}
</script>
</body>
</html>
문맥에 따라 이 답변을 읽어주세요 👍 1

모든 댓글 (4)

more options

For some reason I can't recall, I have a page with a script that detects F9 and Shift+F9 using the keyup event. It works for me in Firefox 21 on Windows 7 -- I can't vouch for "IceWeasel/3.5.16" which is entirely unfamiliar to me...

If you drop this into a page, does it work on your Firefox?

 function keys(key){
   if (!key) {
     key = window.event;
     key.which = key.keyCode;
   }
   if (key.which == 120){ // F9 key
     if (key.shiftKey){
       alert("Shift+F9 pressed!");
     } else {
       alert("F9 pressed without Shift!");
     }
   }
   return false;
 }
 document.onkeyup = keys;
 document.body.focus();

If the IceWeasel detection is incorrect, see: How to reset the default user agent on Firefox.

more options

Thanks jscher2000,

The function you provided, when added to out standard table maintenance html, traps the keypress - without even referencing it anywhere! But, I'm still having trouble getting it to work within a function referenced by the onkeydown property of an element...

Here is the code we have working with other browsers to pop-up contextual help...

The function: function checkKeydown(fnr) {

 // Get Field Specs String from fspecs array
 fhelp = fspecs[fnr];
 // if (window.event.keyCode==120) alert('Caught F9 keypress');
 if (window.event.keyCode==120) create_HelpWindow(fhelp);

}

This is the snippet where we are dynamically building input boxes and we provide the field number as a pointer into the field specifications array: inputline+=' onkeydown="checkKeydown(\+ fnr + '\')"'

So, when a user has the focus in a specific input box, they press the F9 key and a pop-up box containing help about that specific field is displayed... But that approach it isn't working in Firefox...

more options

선택된 해결법

Firefox does not populate window.event like IE does. It never has. Modern browsers can pass the event object from the inline handler. Here's an example. I don't know whether older browsers support this (it works in IE8):

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Test F9 keydown inline handler</title>
</head>
<body>
<p>Try F9<br><input type="text" name="textinput" size="25" value="sample value" onkeydown="keys(event,100)"></p>
<script type="text/javascript">
function keys(evt, arg){
  if (evt.which == 120 || evt.keyCode == 120){ // F9 key
    alert("Function passed: "+arg);
  }
  return false;
}
</script>
</body>
</html>
more options

Thank you for the solution! It works! - (in all the browsers)...