简体   繁体   中英

redirect the page on Java script function alert box (OK) click

below is my java script function on aspx page

<script>
 function alert6() {
            alert("You Can't Delete This Record");
        }
</script>

and use the function on my cs page, i want to redirect the page after the user clicks on OK what i Need to do?

Page.ClientScript.RegisterStartupScript(this.GetType(), "alert5", "alert6();", true);

Simply if you want to redirect the page just after clicking on Ok button of alert box then try this

<script>
 function alert6() {
  alert("You Can't Delete This Record");
  window.location="Your page";
        }
</script>

and call it

Page.ClientScript.RegisterStartupScript(this.GetType(), "alert5", "alert6();", true);

I don't have much knowledge on ASP .NET. But as I understand, you are trying to print out a javascript function to the page which would redirect the page when the OK button is clicked.

As you said you are using JQuery you can use the function below. I am assuming the id of the OK button is 'btnOk'.

$("#btnOk").click(function(){
   window.location = "http://www.yoururl.com";
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM