1

I'm developing TB extension. I've added field to messagePane just below "from, subject, to" fields. So I need to update the field value correctly. I'm getting the value from msgHdr. My current approach is to listen "load" event of the messagePane document. It works fine when there opened only one message in TB. But if there are several opened messages, then every message window gets the same field value, because every window triggers "load" event of last loaded message. It is bug. When I'm receiving load event, how can I determine the msgHdr of message opened in the window? Is it stored somewhere? Have the windows any identity information like handle, uri or something else? Why DOM inspector shows only one DOM node of my field while it exists in every messagePane? Sorry for a bag of questions, I just cannot understand the whole mess with TB windows.

Thanks.

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
alehro
  • 2,198
  • 2
  • 25
  • 41
  • Unlike Firefox's tabbed browser, the tabbed message pane is really only one browser, and when you switch tabs it just reloads the message that was last loaded into that tab. – Neil Feb 23 '11 at 20:25
  • Unbelievable. I doubt if my object oriented mind could rich this by itself. – alehro Feb 24 '11 at 08:21

1 Answers1

3

Message windows have the global variable gMessageDisplay which has the property displayedMessage. displayedMessage is the currently displayed message's nsIMsgDBHdr.

For getting notifications when a new message is displayed I suggest adding a listener to gMessageListeners:

gMessageListeners.push({
  onStartHeaders: function () {},
  onEndHeaders: function () {},
  onEndAttachments: function () {},
  onBeforeShowHeaderPane: function () {}
});

Take your action in onStartHeaders or onEndHeaders.

speedball2001
  • 947
  • 4
  • 7
  • I found that document.getElementById("messagepane").contentDocument.URL containes exactly what I need. Now I want to listen to every change of this stuff. How it can be done? I suppose I could listen to contentDocument load event. But contentDocument isn't permanent by itself, so I probably need to listen to changing of contentDocunt. How it can be done? – alehro Feb 24 '11 at 08:27
  • Or I could simply listen to change of displayedMessage. But I still don't know how to do it. – alehro Feb 24 '11 at 08:47
  • I extended my answer. Hope it helps. – speedball2001 Feb 24 '11 at 16:12
  • It is cool. I met those callbacks many times in sgHeaderViewOverlay.js but completely missed gMessageListeners. You saved me of a lot of nervous. Thanks. – alehro Feb 25 '11 at 07:58