public static string GetAlertScript(string msg, bool startUp)
{
msg = msg.Replace(""n", """n"); // " "n -> ""n
msg = msg.Replace(@"""", @"""""); // " -> ""
string script = string.Empty;
if (startUp)
{
string.Format(@"
$(document).ready(function(){{
alert(""{0}"");
}})", msg);
}
else
{
script = string.Format("alert(""{0}"");", msg);
}
return script;
}
转载于:https://www.cnblogs.com/lishenglyx/archive/2008/12/28/1363952.html