在Javascript弹出窗口中输入换行符

private void showMessage(string strMsg)
        {
            Page.RegisterStartupScript("scriptStr", "<script language='javascript'>alert('"+strMsg+"');</script>");
        }

如何在strMsg中插入换行符?
以便在对话框中反应出来。
______________________________________________________________________________________________
答1:
strMsg = HttpUtility.HtmlEncode(strMsg);
______________________________________________________________________________________________
答2:
Page.RegisterStartupScript("scriptStr", "<script language='javascript'>alert('"+strMsg+"'\\n换行);</script>");

在JS里,换行是\n,在C#里,就需要两个“\\”来表示一个“\”
“\”在C#中是转义字符
______________________________________________________________________________________________
答3:
\r\n

  

posted @ 2013-12-03 12:16  KyrieYang  阅读(6042)  评论(0编辑  收藏  举报