简体   繁体   English

Mozilla Firefox扩展Javascript

[英]Mozilla Firefox Extension Javascript

I am new to Firefox extension. 我是Firefox扩展的新手。 I am not able to understand the following piece of code. 我无法理解以下代码。 Can anyone please explain this. 谁能解释一下。

var httpRequestObserver = var httpRequestObserver =

{ {

observe: function(subject, topic, data)
                    .
                    .

} }

I want to know what does "httpRequestObserver" and "observe" function does. 我想知道“ httpRequestObserver”和“ observe”功能的作用。 I am also searching for tutorials for the same, but couldn't find any. 我也在搜索相同的教程,但找不到任何教程。 It will be really helpful if someone can provide tutorials for the same. 如果有人可以提供相同的教程,那将非常有帮助。

Thanks in advance. 提前致谢。

Have a look at this page at MDN which has sample code related to your example. 在MDN上查看此页面 ,其中包含与您的示例相关的示例代码。

Your httpRequestObserver is an object that will probably later be "registered" to the application Observer Service for notifications on a specific topic , for example http-on-modify-request . 您的httpRequestObserver是一个对象,以后可能会“注册”到应用程序“观察者服务”以获取有关特定topic通知,例如http-on-modify-request

Each time a request is sent, the Observer Service will loop through the list of registered objects for the http-on-modify-request topic and will call their observe method. 每次发送请求时,观察者服务都会循环访问http-on-modify-request主题的已注册对象列表,并将调用它们的observe方法。 This gives the objects a chance to do something with the request before it is actually sent, like adding a custom HTTP header. 这使对象有机会在实际发送请求之前对其进行处理,例如添加自定义HTTP标头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM