Discussion:
[chromium-discuss] Is there a Alternative of onbeforeunload event that can handle on close tab or existing page on a browser?
Junyx Tips
2018-09-13 02:55:46 UTC
Permalink
Hello,


Is there a Alternative of *onbeforeunload *event that can handle on close
tab or existing page on a browser? On chromium policy they stated that on
the new update of chrome they remove the *onbeforeunload *event

This my code which is working other browser except *google chrome*


*<script type="text/javascript">var areYouReallySure = false;function
areYouSure() { if(allowPrompt){ if (!areYouReallySure && true) {
areYouReallySure = true; var hey = "me"; window.location.href =
"google.com"; return hey; } }else{
window.location.href = "google.com"; allowPrompt = true; }}var
allowPrompt = true;window.onbeforeunload = areYouSure;</script>*

Please help... thanks!
--
--
Chromium Discussion mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
You received this message because you are subscribed to the Google Groups "Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discuss+***@chromium.org.
PhistucK
2018-09-13 06:04:37 UTC
Permalink
beforeunload is supported in Chrome. It is ignored without a user
activation (a click on the page or similar interactions), though.
My guess is that the navigation (location.href = "...") is problematic,
though.
Do you know whether your return hey is even reached?
Do you see any error in the console (make sure the console is persisted
across navigations, otherwise the error will be cleared)?

☆*PhistucK*
Post by Junyx Tips
Hello,
Is there a Alternative of *onbeforeunload *event that can handle on close
tab or existing page on a browser? On chromium policy they stated that on
the new update of chrome they remove the *onbeforeunload *event
This my code which is working other browser except *google chrome*
*<script type="text/javascript">var areYouReallySure = false;function
areYouSure() { if(allowPrompt){ if (!areYouReallySure && true) {
areYouReallySure = true; var hey = "me"; window.location.href =
"google.com <http://google.com>"; return hey; } }else{
window.location.href = "google.com <http://google.com>"; allowPrompt
= true; }}var allowPrompt = true;window.onbeforeunload =
areYouSure;</script>*
Please help... thanks!
--
--
http://groups.google.com/a/chromium.org/group/chromium-discuss
---
You received this message because you are subscribed to the Google Groups
"Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
--
Chromium Discussion mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
You received this message because you are subscribed to the Google Groups "Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discuss+***@chromium.org.
Loading...