简体   繁体   中英

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. 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

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

</script>

and my form html is

<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!

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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