で、私はhtmlファイルはHTMLが含まれています:私は、文字列やパスにHTMLに変換するには、次のコードを書くの背後にある.NETのC#コードでパスHTML文字列、.NETでのWebフォーム
<html>
<body>
<div class="infoLabel">*Your order has been placed in production queue</div><br />
<div class="infoLabel">*The order confirmation will be delivered to you shortly</div>
</body>
</html>
〜へJavascript:
string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory.ToString(), "Templates/SiteNotifications/SavedQuote.html");
string htmlBody = File.ReadAllText(path);
ScriptManager.RegisterStartupScript(Page, GetType(), "changePriceList" + Guid.NewGuid(),"displayViewDetails(" + htmlBody + ");", true);
私はhtmlBodyが適切なエスケープ文字列を含んでいることを発見しました。スクリプトは:
function displayViewDetails(currentOrder) {
var w = window.open('_blank', "NewWindow", "width=" + width + ", height=" + height);
w.document.open();
w.document.write(currentOrder);
w.document.close();
}
しかし、デバッグするとき、私はJavaScriptがHTMLを解析するのにエラーがあることがわかりました。私はJavaScriptを解析するためにhtmlを渡す方法を修正する方法はありません。私は、既存の投稿が私の問題を解決するように見えないことを発見しました。誰でも助けることができますか?
は、HTML文字列は、そのに渡されたときのように見えるん何 '文字列は「\ r \ nの \ rを\ nは
\ rを\ nは\ rを\ nは
をdisplayViewDetails' \ r \ n \ r \ n " – DennisL