A disabled submit button remains disabled if a user interrupts a redirect to a new page

I want to disable the submit button after pressing it using javascript.

myForm.onsubmit = function () {... mySubmitButton.disabled = true; ...}

But when the user stops opening a new page while the current is still alive, the button remains disabled.

The same result will be if the content from the server is a file (in this case, there will be no redirection to a new page).

Is there a way to determine if the browser wants to "download" a new URL and enable mySubmitButton again?

+3
source share
2 answers

, setTimeout , . - , 5000 (5 ). , setTimeout/Interval , .

+1

, :

  • , , . .

  • @Adilson, setTimeout , , , - .

  • jQuery ajax-, .

, . , 3 .

+1

Source: https://habr.com/ru/post/1795690/


All Articles