我有这段代码,试图在.NET平台上运行它,但是它无法工作。有没有人知道我的代码出了什么问题?谢谢。我使用的是Visual Studio 2010和C#编程语言。
private void AlertWithConfirmation()
{
Response.Write("<script language='javascript'>");
Response.Write("var x=window.confirm(\"Are you sure you are ok?\")");
Response.Write("if (x)");
Response.Write("window.alert(\"Good!\")");
Response.Write("else");
Response.Write("window.alert(\"Too bad\")");
Response.Write("</script>");
}
<script type="text/javascript">
,你不必使用window.
前缀全局函数,引号混乱是不好的,尽可能在双引号字符串内使用单引号。 - ThiefMaster