How to disable function keys in a PDF displayed in a JSP using <object> and hence to (partially) prevent a Save?

为君一笑 提交于 2020-01-06 07:16:06

问题


I use the following approach to display a PDF within a JSP:

<object id="pdfObj" data='myController.do?#toolbar=0&amp;navpanes=0&amp;scrollbar=1&amp' type='application/pdf' width='100%' height='460px' onkeypress="javascript:alert('key press event not triggered!');"></object>

The toolbar and the navigation panes are hidden when the screen loads. The floating toolbar also is not visible. However, an F8 or a F4 opens up the toolbar or the navigation pane respectively.
An attempt on trapping the keypress or keydown event works for the rest of the screen but once I click within the PDF, the key press events are not captured and this results in the toolbar getting enabled.

I understand that stopping the PDF displayed in the browser from getting saved is not possible, atleast without tha use of any plugin.
However, my question here is more for preventing the function key press just to add one more layer that the user needs to go through to save the document.
[Update] Accommodating @robertc's comment below, can we have a script to capture the function keys at the screen level before that gets handled by the application that handles the embedded object?


回答1:


I was unable to intercept/block/capture the key stroke that was handled by the PDF client (Adobe installed in my system). Accepting comment from @robertc as answer. Since he posted it as a comment, I am moving it here: "you can only block function keys for an application in that application"



来源:https://stackoverflow.com/questions/14581578/how-to-disable-function-keys-in-a-pdf-displayed-in-a-jsp-using-object-and-henc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!