简体   繁体   English

自动提交表单不适用于Chrome

[英]Auto Submit form not working in chrome

I'm having a little issue and I'm not sure how to resolve it. 我遇到了一个小问题,不确定如何解决。 I have a page that auto submits a form and the action of the form is to go to an external url. 我有一个页面,该页面自动提交表单,并且表单的操作是转到外部URL。 The form does not auto submit when it is first loaded but it does so if I refresh the page. 表单在首次加载时不会自动提交,但是如果刷新页面,它会自动提交。 What's going on here then? 那这是怎么回事?

My autosubmit javascript is 我的自动提交JavaScript是

<script type="text/javascript">
  window.onload = function()
   {
     document.subfrm.submit();
   }

</script>

and my form html is 而我的表单html是

<form name="subfrm" action="http://www.theexternalwebsite.com" method="post">
<input type="submit" value="Continue with Payment">

I've probably done something really stupid, my excuse is I'm stressed and have to many looming deadlines. 我可能做过一些非常愚蠢的事情,我的借口是我压力很大,而且必须有很多迫在眉睫的截止日期。 Cheers! 干杯!

right, cracked it. 是的,破解了。 In my form prior to this one I put 在此之前,我以我的形式

data-ajax=false

so the next page is loaded as a normal http..then it did the redirect as expected! 因此下一页将以正常的http加载。然后按预期进行了重定向!

This works: 这有效:

<html>
    <body onload="document.subfrm.submit()">
        <form name="subfrm" action="http://www.theexternalwebsite.com" 
                method="post">
            <input type="submit" value="Continue with Payment">
        </form>
    </body>
</html>​

Demo: http://jsfiddle.net/bensg/1/ 演示: http//jsfiddle.net/bensg/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM