监听来自浏览器“查找"的事件JavaScript 中的窗口

时间:2023-04-20
本文介绍了监听来自浏览器“查找"的事件JavaScript 中的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

有没有办法监听输入浏览器的查找"?JavaScript 中的窗口?

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


(来源:apple.com)

我希望能够从 JavaScript 重新解释搜索文本.我需要为什么添加事件侦听器?

I'd like to be able to reinterpret the search text from JavaScript. What do I need to add an event listener for?

推荐答案

我不知道有什么方法可以监听类似 find 的事件,如果任何浏览器都支持它肯定不是便携式解决方案.

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.

我也不知道您要实现什么,但我认为您最好的选择是侦听触发查找窗口的键盘事件并在尝试模拟查找工具栏/窗口时尝试取消它们使用您自己的 JavaScript.然而,这是一项艰巨(几乎不可能)的任务,因为某些浏览器根据本地化自定义键盘快捷键(例如,在 IE 中,en-US 使用 Ctrl+F(用于 Find)而 pt-PT 使用 Ctrl+L(对于 Localizar,意思是查找).

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...

这篇关于监听来自浏览器“查找"的事件JavaScript 中的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:JavaScript 如何识别事件对象变量? 下一篇:JavaScript 中的保留函数名

相关文章