문제

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