对于像帧这样的东西,你可以得到所有帧的列表,比如window.frames
。您可以对EventSource
做同样的事情吗?或者我可以为所有事件创建一个全局事件侦听器吗?
// Attach an event listener to the window object
window.addEventListener("*", function(event) {
// The event object contains information about the event that was triggered
console.log(event.type); // Outputs the type of event that was triggered (e.g. "click", "submit", etc.)
});
获取所有EventSource对象的列表是不可能的,你可以使用window.frames属性获取所有帧的列表。但是,您可以使用EventSource. addeventlistener()方法将事件侦听器附加到特定的EventSource对象,并侦听由该对象发送的事件。