I think listening in the background page on the onunload event should
work. I just added this code to a test extension and I could see both
counts incrementing every time I shut down and relaunched the browser:
window.onload = function() {
if (!localStorage.onloadCount)
localStorage.onloadCount = 1;
else
localStorage.onloadCount++;
console.log(localStorage.onloadCount);
console.log(localStorage.onunloadCount);
};
window.onunload = function() {
if (!localStorage.onunloadCount)
localStorage.onunloadCount = 1;
else
localStorage.onunloadCount++;
};
On Tue, Dec 15, 2009 at 5:58 PM, Tiby312 <[email protected]> wrote:
> Hmm, but that'd only work if the user closed chrome when it only had
> one tab left when a user could close chrome when it had any number of
> tabs open. :(
>
> I guess I'll just have the code be executed at the close of every tab.
>
> On Dec 15, 9:01 am, "Luca C." <[email protected]> wrote:
>> Hi,
>>
>> you can try to add an event handler each time a tab is closed and
>> counting the number of open tabs. When this counter goes lower than 2
>> than the Chrome is going to be shut down.
>>
>> I hope it helps!
>>
>> Luca
>>
>> On 15 Dic, 02:43, Tiby312 <[email protected]> wrote:
>>
>>
>>
>> > I gave it a shot and the code seems to run if I close the extension by
>> > pressing the disable button of the extension in the extensions page,
>> > but the code doesn't run if I just close the browser. :(
>>
>> > On Dec 14, 6:23 pm, Marcos Aruj <[email protected]> wrote:
>>
>> > > What you can try is the adding a listener to the uninit event of the
>> > > background script, but I haven't tried it. But may work.
>> > > ;)
>>
>> > > On Sun, Dec 13, 2009 at 5:22 PM, Tiby312 <[email protected]> wrote:
>> > > > Is there an event listener for when chrome is closed? I tried using
>> > > > the window close event, but it doesn't work for when you close the
>> > > > last window. So how would one get some code to execute at that moment?
>>
>> > > > --
>>
>> > > > You received this message because you are subscribed to the Google
>> > > > Groups
>> > > > "Chromium-extensions" group.
>> > > > To post to this group, send email to
>> > > > [email protected].
>> > > > To unsubscribe from this group, send email to
>> > > > [email protected]<chromium-extensions%2Bunsu
>> > > > [email protected]>
>> > > > .
>> > > > For more options, visit this group at
>> > > >http://groups.google.com/group/chromium-extensions?hl=en.
>>
>> > > --
>> > > Marcos Aruj Alvarez
>> > > Ingeniero de Software
>> > > -------------------------------
>> > > [email protected]
>> > > -----
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Chromium-extensions" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/chromium-extensions?hl=en.