WindowsPhone 7.8 で WebBrowser コントロールを使用しているときに、javascript に問題があります。onClick メソッドを使用している場合はhref="#"
正常に動作しますが、変更するとhref="javascript:;"
onClick メソッドが動作しません。WindowsPhone Web ブラウザーで使用しようとしましたが、問題はありません。両方のリンクが正しく機能します。
これが私のテストページの完全なコードです(http://klamborowski.pl/test/js.html):
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl">
<head>
<title>
</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-2" />
<script type="text/javascript">function post_to_url() {
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "http://stackoverflow.com/");
document.body.appendChild(form);form.submit();
}
</script>
</head>
<body>
<b>
<a href="javascript:;" onclick="post_to_url();">Click <br>here - javascript:;</a> <br>
<br>
<br>
<br>
<a href="#" onclick="post_to_url();">Click <br>here - #</a> <br>
</b>
</body>
</html>
およびそれを使用する C# コード:
myWebBrowser.IsScriptEnabled = true;
myWebBrowser.Navigate(new Uri("http://klamborowski.pl/test/js.html"));
ヒントとヘルプをお寄せいただきありがとうございます。
編集: これは単なるサンプル ページです。私の実際のプロジェクトでは、支払いを含むサードパーティのページ (を含むhref="javascript:;"
) を使用していますが、変更を加えることはできません。