Onbeforeunload not working in chrome version 80


Joined
Feb 27, 2020
Messages
6
Reaction score
0
Hi,

I have a datatable on page and I have search functionality for the datatable on the page.when i try to search string it filters datatable. And when I redirect to another page and again come back to the same page the search filter(datatable ) retains.

I have written down function on onbeforeunload event as below

var unloadCatcher = function() {
var dateObjAjax = new Date();
var timestamp = dateObjAjax.getTime();
var sortColumnIndex = $('#example').dataTable().fnSettings().aaSorting[0][0];
var pageType = "EPPatientList";
var paginationSize = $("#example_length select option:selected").prop('value');
var sortDirection = $('#example').dataTable().fnSettings().aaSorting[0][1];
var searchText = "";
if ($('#search_input').is(':visible')) {
searchText = $('#search_input').val();
$("#hiddenSearchText").val(searchText);
}
else {
$("#hiddenSearchText").val("");
}

$.ajax({
url: "<%=userPreference%>&sortColumnIndex=" + sortColumnIndex
+ "&pageType=" + pageType
+ "&paginationSize=" + paginationSize
+ "&sortDirection=" + sortDirection
+ "&time="+timestamp,
type: "post",
data: $("#hiddenSearchForm").serialize(),
cache: false,
async: false,
success: function(data){
}
});

var otable = $('#example').DataTable();
var pageSize = otable.page.info().length;

var expdate = new Date();

expdate.setTime(expdate.getTime() + (60 * 60 * 1000 * 24 * 365 * 20));
$.cookie('SJM_PT_'+userLogonCookieName+'_PageSize',pageSize,{ expires: expdate });
}

window.onbeforeunload = unloadCatcher;

currently this function (window.onbeforeunload = unloadCatcher;) doesn't work for me as I am using chrome 80.

And as per my knowledge Chrome version 80 does not support window.onbeforeunload events any more instead there are two new calls fetch and sendBeacon is supported in Chrome and other browsers except IE11. So is there any alternative?

Thanks in advance
 
Ad

Advertisements

Joined
Nov 27, 2019
Messages
128
Reaction score
19
You are using either vue, react, or angular js along with jquery. You need to go to a forum that specializes in those frameworks. Each abomination has their own users forum and help center. Use google to look up where.
 
Joined
Feb 27, 2020
Messages
6
Reaction score
0
We are not using any framework.The application is in jquery and backend java
Also we have used datatables to render data in table.
 
Last edited:
Ad

Advertisements

Joined
Nov 27, 2019
Messages
128
Reaction score
19
"We are not using any framework.". That is what jquery is - a framework.
I use Version 80.0.3987.122 (Official Build) (64-bit) and window.onbeforeunload is supported, but it is a fickle function and does not always work. The browser does not make a difference.
I bow out; if you receive no help from my constituents try another forum.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top