0

I'm developing a web solution to run in the clients existing portal. In this portal they already handle F1 differently from the default behaviour.

I would like to add a "Help" icon to my solution that when clicked simulates pressing F1. Of course I would like the solution to be as cross browser compatible as possible but the final version will run solely in Internet Explorer 8 (and actually with the compatibility button pressed - GRRRR).

I have found numerous functions to handle pressing F1 but non that describes how to simulate pressing F1 programmatically.

I'm using jQuery 1.8.2 if that helps...

Thanks in advance

CJe
  • 1,928
  • 3
  • 24
  • 53
  • What is the reason that they still run in IE8 (also with compatibility mode)? If I had a client that would run IE8 in compat. mode using the application I developed, I would require either a good browser that they use or that they drop this requirement. – Sander Feb 14 '13 at 08:38
  • The client has 25.000+ employees and are always quite late in updating their software. A lot of employees are still running XP(!). So it's out of my hands... – CJe Feb 14 '13 at 09:24
  • Ah ok, understandable :) I was just wondering. – Sander Feb 14 '13 at 09:43

3 Answers3

1

You can use this to catch the event in IE:

and use these to fire the event:

Community
  • 1
  • 1
Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
  • Using the example from openwritings I get an "undefined method" when calling dispatchEvent... – CJe Feb 14 '13 at 11:42
0

On this page https://github.com/jeresig/jquery.hotkeys#readme there is this quote: "Others, (IE) either let you handle built-in short-cuts, but will add their functionality after your code has executed. Or (Opera/Safari) will not pass those events to the DOM at all. So, if you bind Ctrl-Q or Alt-F4 and your Safari/Opera window is closed don't be surprised."

Which means that you probably can't do what you want to do, as pressing F1 will launch the help from Windows.

Sander
  • 1,244
  • 1
  • 12
  • 24
  • Well the portal for which I'm developing a frame already handles this but that's when pressing F1 on the keyboard. I want to click an icon and simulate pressing F1. – CJe Feb 14 '13 at 11:21
0
jQuery.event.trigger({ type : 'keypress', which : 112 });
nozzleman
  • 9,529
  • 4
  • 37
  • 58
  • Hmm... can't get this to work. Trying in Chrome where I normally get a new help tab. This does nothing. Same in IE. – CJe Feb 14 '13 at 11:22
  • huh, I'm pretty sure that this is the correct keycode. may if you trigger `keyup` instead? – nozzleman Feb 14 '13 at 13:34
  • 1
    Nope :-( Nothing. In Chrome when I press F1 I get a new tab with Chrome help. Clicking a link executing the code above (or with keyup) does nothing :-( I'll have to figure something else out. Thanks for the effort everyone. – CJe Feb 15 '13 at 06:56