This is a piece of my function with the question in it:
function deletePost() { var ask = window.confirm("Are you sure you want to delete this post?"); if (ask) { window.alert("This post was successfully deleted."); /* How to redirect to another page on confirm? */ } }
Pure Javascript needed.
You cannot run an alert after the location. href has changed because it causes the browser to refresh. Once refreshed, your script is no longer running. You would need to move your alert script into your search page and perhaps pass the name as a querystring arguement.
confirm() instructs the browser to display a dialog with an optional message, and to wait until the user either confirms or cancels the dialog.
To redirect URL to a different website after few seconds, use the META tag, with the content attribute.
try this:
function deletePost() { var ask = window.confirm("Are you sure you want to delete this post?"); if (ask) { window.alert("This post was successfully deleted."); window.location.href = "window-location.html"; } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With