復制代碼 代碼如下:
/// <summary>
/// 提供一個可選“是”“否”的彈出窗口,若選是,則跳到url1,選否則跳到url2
/// </summary>
/// <param name="strMsg"></param>
/// <param name="url1">選“是”</param>
/// <param name="url2">選“否”</param>
public static void confirm(string strMsg, string url1, string url2)
{
Page page = HttpContext.Current.Handler as Page;
page.ClientScript.RegisterStartupScript(page.GetType(), "message", "var result = window.confirm('" + strMsg + "');if(result){window.location='" + url1 + "'}else{window.location='" + url2 + "'};",true);
return;
}