Safari 扩展 beforeload 事件文档
除了 阻止不需要的内容部分。
我特别寻找的是事件消息结构。从上面的文档中我知道有一个 event.url
成员,但没有太多其他的。从源代码片段中我知道还有一个 event.target.nodeName 成员。但除此之外我什么也没有了。
我迷失在 WebKit 文档和 w3 事件文档中。在哪里可以找到 beforeload
事件的一些简单参考文档?
I can't find any documentation on the beforeload
event other than the Blocking Unwanted Content section of this.
What I'm specifically looking for is the event message structure. From the above doc I know that there is a event.url
member, but not much else. From a snip of source code I know there's also a event.target.nodeName
member. But I don't have anything more than that.
I got lost in both the WebKit docs and w3 event docs. Where can I find some simple reference documentation for the beforeload
event?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
DOM beforeload 事件是一个 WebKit 概念,它并不特定于 Safari 扩展。它确实有一个 URL 属性。
有关 beforeload 事件的更多信息 - 您可以查看:
http: //opensource.apple.com/source/WebCore/WebCore-1298/dom/BeforeLoadEvent.idl
如果您在扩展内容脚本中使用此脚本,获取更多信息的一种方法是使用一些代码,例如:
然后使用Web Inspector查看有关事件的信息(您可以看到它的URL,您可以查看事件目标等)。
The DOM beforeload event is a WebKit concept, it is not specific to Safari extensions. It does have a URL property.
For some more information about the beforeload event - you can see:
http://opensource.apple.com/source/WebCore/WebCore-1298/dom/BeforeLoadEvent.idl
If you are using this in an extension content script, one way to get some more information about be to have some code like:
And then use the Web Inspector to view information about the event (you can see its URL, you can look at the event target, etc).
事件消息(
SafariExtensionMessageEvent
实例)只有一个名称
和一个消息
(类文档)。它实际上在 同一页面。有趣的是,事件类(SafariEvent) 文档没有提及
url
属性或方法,因此要么正在传递不同类的对象,要么正在发生其他情况。和你一样,我也发现苹果的文档充其量是不足的。为了编写我想要编写的小扩展,我必须将文档中各个位置的信息拼凑在一起。如果您想知道您是否是唯一一个必须非常努力地工作才能完成相对简单的任务的人……您不是。 :-)
Event messages (
SafariExtensionMessageEvent
instances) only have aname
and amessage
(class documentation). It's actually discussed on the same page.Interestingly, the event class (SafariEvent) documentation doesn't mention a
url
property or method so either an object of a different class is being passed or something else is going on.Like you, I've found Apple's documentation to be wanting, at best. To write the small extensions I've wanted to write, I've had to cobble together information from various locations within the docs. If you're wondering whether you're the only one that's had to work way too hard to complete relatively straightforward tasks...you're not. :-)
当从页面内容使用时,该示例应将 capture 参数设置为“true”,而不是“false”。我不确定这将如何影响它在扩展中的使用,但人们直接从页面内容中使用它并使用它来重写页面。在这种情况下你需要捕捉。
The example should set the capture argument to 'true', not 'false' when used from page content. I'm not sure how that will affect its use in extensions, but people are using this from page content directly and using it to rewrite pages. And you need to capture in that case.