Popup Closed Event?

1,720 views
Skip to first unread message

doubleTap

unread,
Oct 28, 2011, 1:50:12 PM10/28/11
to Chromium-extensions
I am trying to notify the background when the pop up has been closed.
It does not seem that there is an event in the API to which I can
subscribe and I have tried sending messages via a function attached to
window.onbeforeunload but, that event does not seem to fire in the pop
up. Is there a way I can notify the background that the pop up has
been or is being closed?

PhistucK

unread,
Oct 28, 2011, 1:53:31 PM10/28/11
to doubleTap, Chromium-extensions
Have you tried window.onunload?

PhistucK




--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


doubleTap

unread,
Oct 28, 2011, 2:11:40 PM10/28/11
to Chromium-extensions
I have tried onunload. I am have tested this using a port and using
chrome.extension.sendRequest. Both of these messaging patterns work
otherwise before the unload event. I think I have ruled out messaging
as the potential issue. So, the event seems to be the issue. I could
see onbeforeunload being disabled because it typically creates a
dialog in normal instances which does not seem to be allowed in
general from a popup. Summarizing, the event seems to be the issue and
I have tried before and on unload.

On Oct 28, 10:53 am, PhistucK <phist...@gmail.com> wrote:
> Have you tried window.onunload?
>
> ☆*PhistucK*
>
>
>
>
>
>
>
> On Fri, Oct 28, 2011 at 19:50, doubleTap <a...@adambragg.com> wrote:
> > I am trying to notify the background when the pop up has been closed.
> > It does not seem that there is an event in the API to which I can
> > subscribe and I have tried sending messages via a function attached to
> > window.onbeforeunload but, that event does not seem to fire in the pop
> > up. Is there a way I can notify the background that the pop up has
> > been or is being closed?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Chromium-extensions" group.
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to
> > chromium-extensions+unsubscr...@chromium.org.

Scott Fujan

unread,
Oct 28, 2011, 2:14:40 PM10/28/11
to PhistucK, doubleTap, Chromium-extensions
onunload works, and I figure that onbeforeunload would work. You can definitely use chrome.extension.getBackgroundPage() to interact with the background page in an onunload listener.

PhistucK

unread,
Oct 28, 2011, 3:29:30 PM10/28/11
to Scott Fujan, doubleTap, Chromium-extensions
Exactly what I was about to send.

PhistucK

doubleTap

unread,
Oct 28, 2011, 3:32:13 PM10/28/11
to Chromium-extensions
That is odd. I can't get onunload to work with either the port or
sendRequest.

On Oct 28, 12:29 pm, PhistucK <phist...@gmail.com> wrote:
> Exactly what I was about to send.
>
> ☆*PhistucK*
>
>
>
>
>
>
>
> On Fri, Oct 28, 2011 at 20:14, Scott Fujan <sc...@fujan.name> wrote:
> > onunload works, and I figure that onbeforeunload would work. You can
> > definitely use chrome.extension.getBackgroundPage() to interact with the
> > background page in an onunload listener.
>
> > On Fri, Oct 28, 2011 at 12:53 PM, PhistucK <phist...@gmail.com> wrote:
>
> >> Have you tried window.onunload?
>
> >> ☆*PhistucK*
>
> >> On Fri, Oct 28, 2011 at 19:50, doubleTap <a...@adambragg.com> wrote:
>
> >>> I am trying to notify the background when the pop up has been closed.
> >>> It does not seem that there is an event in the API to which I can
> >>> subscribe and I have tried sending messages via a function attached to
> >>> window.onbeforeunload but, that event does not seem to fire in the pop
> >>> up. Is there a way I can notify the background that the pop up has
> >>> been or is being closed?
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups
> >>> "Chromium-extensions" group.
> >>> To post to this group, send email to chromium-extensi...@chromium.org.
> >>> To unsubscribe from this group, send email to
> >>> chromium-extensions+unsubscr...@chromium.org.
> >>> For more options, visit this group at
> >>>http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en
> >>> .
>
> >>  --
> >> You received this message because you are subscribed to the Google Groups
> >> "Chromium-extensions" group.
> >> To post to this group, send email to chromium-extensi...@chromium.org.
> >> To unsubscribe from this group, send email to
> >> chromium-extensions+unsubscr...@chromium.org.

PhistucK

unread,
Oct 28, 2011, 3:49:00 PM10/28/11
to doubleTap, Chromium-extensions
No, do not use sendRequest/port, use chrome.extension.getBackgroundPage() directly.
It will give you the global (window) object of the background page and you can do whatever you want with it.

PhistucK



To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
Reply all
Reply to author
Forward
0 new messages