Search code examples
javascripthtmlconfirmation

navigate to html page within javascript


Have a confirmation window before submitting, but after returning true(confirm submission) also needs to go to confirmation page.

Have this:

<button type="submit" value="Save" id="Save" onclick="clicked();" >Submit Form</button>

function clicked() {
   if (confirm('Are you sure you want to submit? You will not be able to go back.')) {
       yourformelement.submit();
   } else {
       return false;
   }
}

Trying to include 'go to' location.href='Confirmation.html' somewhere but unsure exactly how. Any input would be appreciated.


Solution

  • The form will not be submitted asynchronously as far as I can see. The server will be able to redirect your browser to another page, by replying with a "Location" header to the form submission.