每当用户点击地址栏中的Enter键时,Firefox插件就会执行某些操作 [英] Firefox addon to do something everytime a user hits Enter in the address bar

查看:148
本文介绍了每当用户点击地址栏中的Enter键时,Firefox插件就会执行某些操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个扩展程序,以便在使用地址栏时每次输入匹配时都会进行监视。用户输入地址栏中的一堆文本并点击输入 $ $
$ b

I'm trying to write an extension that monitors every time someone types hits enter when using the address bar. The steps would be something along the lines of


  1. b $ b
  2. 我的附加程序会跳出生命并收到用户输入的内容。
  3. 然后,我的插件决定如何处理用户输入的字符串。

通过使用 var url = window.location.href 获取第二步中的url。我也已经把第3步写出来了。唯一可能我似乎无法弄清的是如何监视每个标签,以查看用户点击返回。

I get the url in step 2 by using var url = window.location.href. I also have most of step 3 written out already. The only probably I can't seem to figure out is how to monitor every tab to watch for when the user hits return.

我真的是新的JavaScript,但无论如何,任何信息将不胜感激。

I'm really new to javascript, but regardless of that, any information would be appreciated.

这就是myaddon.xul文件的样子:

This is what my myaddon.xul file looks like:

<overlay id="sample" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://myaddon/content/myaddon.js" />
<textarea id="urlbar" ontextentered="return myaddon_URLBar(param);" />

p>

推荐答案

我想下面的链接会有所帮助。您需要实现Progress Listener,只要发生与文档相关的事件,就可以通知扩展。您也可以将其扩展到多个选项卡。
请尝试链接

I think the following link would help. You need to implement Progress Listeners, they allow extensions to be notified whenever some events happen associated with the document. You can also extend this to multiple tabs. Please try the link

https://developer.mozilla.org/en/Code_snippets/Progress_Listeners#Example.3a_Notification_when_the_value_in_Address_Bar_changes

希望它能帮助:)

这篇关于每当用户点击地址栏中的Enter键时,Firefox插件就会执行某些操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆