Listen for Events from Browser “Find” Window in JavaScript

前端 未结 3 536
鱼传尺愫
鱼传尺愫 2020-12-21 03:41

Is there a way to listen for typing into the browser\'s \"find\" window in JavaScript?

\"thi

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-21 04:41

    I don't know of any way you can listen for a find-like event and if that's supported in any browser it sure isn't a portable solution.

    I also don't know what you're trying to achieve but I think that your best option is to listen for the keyboard events that trigger the find window and attempt to cancel them while attempting to emulate the find-toolbar/window with JavaScript of your own. This is however a herculean (and nearly impossible) task due to some browsers customization of keyboard shortcuts depending on the localization (for instance, in IE, en-US uses Ctrl+F (for Find) while pt-PT uses Ctrl+L (for Localizar, meaning find)).

    Conclusion: I think you're out of luck there...

提交回复
热议问题