English 中文(简体)
2. 改头后的红树脂重质
原标题:Safari resends same form after redirect
  • 时间:2012-05-02 19:40:43
  •  标签:
  • safari

I am currently experiencing a bug that only occurs in the current version of Safari (5.1.5) and was wondering if anyone here could come up with any workarounds for it. I tested it in 5.1.2 and it worked fine there, I m not sure about 5.1.3 and 5.1.4 as I don t have access to those releases.

bug需要三页,我用三页显示这些文件的来源,然后解释正在做些什么:

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");
}

你注意到这两种表格都有相同的外地名称,但其中一个领域具有不同的价值。 然而,在操作该代码时,该数值为<代码>1234”,以<代码>不同>的外地/代码取代<代码>5678”。 我不认为这一丑闻有任何意义。 NET,但我没有容易地测试另一种语言,以确保这一点。

Things I already tried:

  • Putting the form submission code in a function and then calling that.
  • Requiring Jquery and calling it in the $(document).ready() function.
  • Putting the function call in a setTimeout().
  • Replacing the function with a button that I press.
  • Copying the Handler and sending the second form to the copy instead.

Every single one of these methods had the same effect, which is to print "Failure" instead of Success.
I will be filing this bug on the Safari forums (I don t have an Apple Developer account and it s not working to create a new one at the moment), but I was hoping that someone could help me come up with a suitable workaround for this problem until they fix it.

EDIT: The Safari Forum bug report:

最佳回答

NicolasIgot on my safari forum figured out a solution to my problem.

I just added autocomplete="off" to the form tag on the second form and everything started working again. I haven t tried it on my real problem, but it works on my simple test case, so I have confidence in it.

问题回答

暂无回答




相关问题
Font Rendering between Mozilla and webkit

I m not sure if this has anything to do with the recent Safari update, but I m beginning to notice this a lot. There is a drastic difference in the way each browser is rendering fonts. for instance, ...

How i can track Safari activity from my application

I have to develop an application to monitor Safari activity like all open url , tabs on particular window and loding time of particular url. I also need to track online streaming that is happening on ...

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

How to get a flash url in a webpage using a webframe?

As we know , When we load frame from webpage of safari, we will invoke the delegate methods of webkit informal protocol(WebFrameLoadDelegate): webView:didStartProvisionalLoadForFrame: webView:...

热门标签