Triggering Ctrl S or Ctrl P via a button

有些话、适合烂在心里 提交于 2019-12-01 06:38:18

If you want to trigger your own handler code, you should just put that code in a separate function and call the function normally.

If you want to trigger the browser's default functionality, you should give up; that is impossible for security reasons. (Although you may be interested in window.print())

rtpHarry

I don't know if you can trigger the key presses but perhaps if you explain what you are specifically trying to achieve you might be able to find a solution?

For example, if you want to trigger ctrl-p to bring up the print dialog you can do this using window.print();

If you want to trigger actions in your own code then you can just call the code directly rather than triggering the key press.

I don't think there is any way to trigger a file | save as (ctrl-s) by using JavaScript though.

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