I have a piece of JS code as follows:
window.onbeforeunload = function saveFav() {
//Some JS code
}
Now this same function needs to be called from a link click handler, so I am just directly calling the function as:
$("#someLink").click(function() {
saveFav();
});
But for some reasons saveFav() is not getting called from link click. Is there some syntax issue OR will the function be called only on page unload?
I do not want to replicate the code as it is same on both unload and link click.
Please help me.