"Force Remove" Tab or Window, (ignoring onbeforeunload & onunload)?

532 views
Skip to first unread message

John Beales

unread,
Oct 23, 2011, 11:45:59 AM10/23/11
to Chromium-extensions
When using chrome.tabs.remove() I'd like to be able to force it, so
that I don't have to confirm in the annoying onbeforeunload/onunload
dialog box. Does anyone know of a way to make this happen?

I've tried setting the tab's window.onbeforeunload and window.onunload
events to an empty function and it helps, but doesn't always work,
(I'm guessing some particularly determined webmasters constantly re-
assign their onbeforeunload functions).

Thanks,

John

PhistucK

unread,
Oct 28, 2011, 6:49:40 AM10/28/11
to John Beales, Chromium-extensions
Either that, or they use addEventListener("beforeunload", ...), which emptying window.onbeforeunload does not remove.
Have you tried, maybe, to assign window.onbeforeunload a function that only calls event.stopImmediatePropagation()?
I am not sure, though, which listener is called first (the window.onbeforeunload or the addEventListener one), or whether this method actually prevent other listeners from being called, so this might now work at all.

Oh, this is probably an overkill, but you might want to addEventListener at document_start (with an always applied content script) that will do whatever you choose to do afterward (event.stopImmediatePropagation() or nothing).

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.


Reply all
Reply to author
Forward
0 new messages