Вопрос

Let's suppose I have a form with some input fields and a submit button.

If I use the window.onunload, is it possible for me to trigger the submit button before the user leaves the webpage.

Which would be the correct way to implement it.

Это было полезно?

Решение

Something like the following might work:

$(window).unload(function() {
  document.getElementById('YOURBUTTONID').submit();
});
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top