Friday 10 November 2017

javascript - Redirect to other page on alert box confirm





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.


itemprop="text">
class="normal">Answer



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";


}
}



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...