window.onbeforeunload didn't work correctly
-
I am a web developer. I added some javascript code in my web application which is performing some action on the window.onbeforeunload event. But it seems like, the event is not calling if you click on the back button or reload button etc. I would appreciate if you fix this issue. Other browsers work perfectly with this event. but Vivaldi ignores the code and just simply navigate to the previous history or reload the page.
-
@imtiaz Try
popstate
for back and forward buttons instead. Should work as expected. -
@gwen-dragon yeah sure.
-
@luetage unfortunately, I am facing the same issue on popstate as well. here is the code example.
$(window).on("popstate", function (e) { if(unsaved) { // my code here } });
-
@imtiaz That's strange, I'm using popstate in one of my extensions and it works as expected, just tested it. I'm using normal javascript instead of jQuery, but that shouldn't really make any difference?
-
@luetage that's what I am facing. Code is just working fine on other browsers(like chrome, Edge, Firefox, Opera). But didn't work on Vivaldi. I uploaded a test file on "http://codeonion.com/test_back_prompt_fields.php". Can you check on your Vivaldi browser? Just add some text in text field and then try to reload the page. It should prompt you a warning message. (don't click on "oka" button. it does nothing)
-
@imtiaz Yeah, doesn't work and doesn't throw an error either.
-
Any update regarding this issue?
Mod Edit: Because threads were merged.
-
This post is deleted! -
This post is deleted!