私はそれを手に入れました! ファイルは多かれ少なかれ正確でしたが、私は2つの間違いを犯しました。 まず、HTMLファイルの最初の行にスペースが必要です。
<!-- saved from url=(0014)about:internet -->
代わりの
<!--saved from url=(0014)about:internet-->
さらにコンテンツがStringBuilderを経て作成されたため、HTMLのデザインが悪かったし、結果は長い文字列だったので、何の構造がありませんでした。 StringBuilderの代わりにstring型の配列を使用する必要があり、StreamWriterを使用して配列を書き込む必要があります。 だから、これが機能するようになりました新しいコードです:
List<string> htmlContent = new List<string>();
htmlContent.Add("<!-- saved from url=(0014)about:internet -->");
htmlContent.Add("<!DOCTYPE html>");
htmlContent.Add("<html lang=\"de\" xmlns=\"http://www.w3.org/1999/xhtml\">");
htmlContent.Add("<head>");
htmlContent.Add("<meta charset=\"utf-8\" content=\"IE=9\" />");
htmlContent.Add("<title></title>");
htmlContent.Add("</head>");
htmlContent.Add("<body>");
htmlContent.Add("<form>");
htmlContent.Add("<div id =\"pagecontent\">");
htmlContent.Add("<label>Wert 1</label><br/>");
htmlContent.Add("<input id =\"Wert1\" type=\"text\" maxlength=\"7\" placeholder=\"___,__\" title=\"Please use format ###,##\" pattern=\"^[+-]?\\d{0,3}((\\.|,)\\d{1,2})?\" style=\"font-family:Arial; font-style:normal; font-weight:normal; font-size:12px; text-align:left; height:20px; width:120px;\" /><br/>");
htmlContent.Add("<label>Wert 2</label><br/>");
htmlContent.Add("<input id =\"Wert2\" type=\"text\" maxlength=\"7\" placeholder=\"___,__\" title=\"Please use format ###,##\" pattern=\"^[+-]?\\d{0,3}((\\.|,)\\d{1,2})?\" style=\"font-family:Arial; font-style:normal; font-weight:normal; font-size:12px; text-align:left; height:20px; width:120px;\" /><br/>");
htmlContent.Add("<label>Ergebnis</label><br/>");
htmlContent.Add("<input id =\"Wert3\" readonly type=\"text\" disabled maxlength=\"7\" placeholder=\"___,__\" title=\"Please use format ###,##\" pattern=\"^[+-]?\\d{0,3}((\\.|,)\\d{1,2})?\" style=\"font-family:Arial; font-style:normal; font-weight:normal; font-size:12px; text-align:left; height:20px; width:120px;\" /><br/>");
htmlContent.Add("<script src =\"scripts/ValidationFunctions.js\"></script>");
htmlContent.Add("<script src =\"scripts/jquery-2.2.4.min.js\"></script>");
htmlContent.Add("<script type =\"text/javascript\">");
htmlContent.Add("$(\"#pagecontent\").keyup(function() {CalculationTest();});");
htmlContent.Add("$(\"#pagecontent\").change(function() {CalculationTest();});");
htmlContent.Add("function CalculationTest() {var value_Z = parseFloat(ValidateNumberValue(document.getElementById(\"Wert1\").value.replace(\",\", \".\")));var value_RBMAX = parseFloat(ValidateNumberValue(document.getElementById(\"Wert2\").value.replace(\",\", \".\")));if (value_Z != 0 && value_RBMAX != 0) {document.getElementById(\"Wert3\").value = (value_Z*100/value_RBMAX).toFixed(2);} else {document.getElementById(\"Wert3\").value = null; }}");
htmlContent.Add("</script>");
htmlContent.Add("</div>");
htmlContent.Add("</form>");
htmlContent.Add("</body>");
htmlContent.Add("</html>");
string curDir = System.IO.Directory.GetCurrentDirectory();
string filePath = curDir + "\\calctest.html";
if (System.IO.File.Exists(filePath))
System.IO.File.Delete(filePath);
System.IO.FileStream fs = System.IO.File.OpenWrite(filePath);
System.IO.StreamWriter sw = new System.IO.StreamWriter(fs, Encoding.UTF8);
foreach (string htmlLine in htmlContent)
{
sw.WriteLine(htmlLine);
}
sw.Close();
string pagePath = string.Format("file:///{0}/calctest.html", curDir).ToString();
wbcWebBrowser.Navigate(new Uri(pagePath));
https://stackoverflow.com/questions/940435/changing-active-content-security-settings-on-wpf-webbrowser-control/27917886#27917886 – vidriduch
こんにちはvidriduch!上記のように、localhostバリアントを試してみましたが、動作しません。結果は同じです。 –