私は現在、現在のバージョンの Safari (5.1.5) でのみ発生するバグに遭遇しており、ここで誰かが回避策を思い付くことができるかどうか疑問に思っていました。5.1.2 でテストしたところ、問題なく動作しました。5.1.3 と 5.1.4 については、これらのリリースにアクセスできないため、わかりません。
このバグには 3 つのページが必要です。それらのソースを示してから、何が起こっているのかを説明します。
FirstPageWithForm.htm
<form id="theForm" action="ActionHandler.ashx" method="post">
<input type="hidden" name="differentField" value="1234"/>
<input type="hidden" name="sameField" value="1111"/>
</form>
<script type="text/javascript">
var theForm = document.getElementById("theForm");
theForm.submit();
</script>
SecondPageWithForm.htm
<form id="theForm" action="ActionHandler.ashx" method="post">
<input type="hidden" name="differentField" value="5678"/>
<input type="hidden" name="sameField" value="1111"/>
</form>
<script type="text/javascript">
var theForm = document.getElementById("theForm");
theForm.submit();
</script>
ActionHandler.ashx
public void ProcessRequest(HttpContext context)
{
var referrer = context.Request.UrlReferrer;
var differentField = context.Request["differentField"];
context.Response.Write(differentField);
if (differentField == "1234")
{
if (referrer.ToString().Contains("Second"))
context.Response.Write("Failure");
else
{
context.Response.Redirect("SecondPageWithForm.htm");
}
}
else
context.Response.Write("Success");
}
お気づきのように、両方のフォームのフィールド名は同じですが、フィールドの 1 つは異なる値になっています。ただし、Safari でこのコードを実行すると、値はではなく"1234"
として送信されます。このバグが .NET と関係があるとは思いませんが、それを確認するために別の言語をテストする簡単な方法がありません。differentField
"5678"
私がすでに試したこと:
- フォーム送信コードを関数に入れ、それを呼び出します。
- Jquery を要求し、$(document).ready() 関数で呼び出します。
- 関数呼び出しを setTimeout() に入れます。
- 機能を私が押すボタンに置き換えます。
- ハンドラーをコピーし、代わりに 2 番目のフォームをコピーに送信します。
これらのメソッドはどれも同じ効果があり、Success ではなく "Failure" を出力します。
このバグは Safari フォーラムに報告する予定です (私は Apple Developer アカウントを持っておらず、現時点では新しいアカウントを作成することはできません)。彼らがそれを修正するまで、この問題。
編集: Safari フォーラムのバグ レポート: https://discussions.apple.com/thread/3921507