Please sign in to get the most from this site.

Integrating an Act-On Form External Post with WordPress

1
Follow

Comments

1 comment

  • Avatar
    Adal Bermann

    The javascript provided for the #_Standard_Implementation:_Page_Method is not working properly because it relies on window.onload.

    This article explains why that is a problem: https://ckon.wordpress.com/2008/07/25/stop-using-windowonload-in-javascript/

    Below is my revised script, including a conditional statement to avoid it being printed elsewhere than on the relevant Thank You pages.
    Note also that I included the ActOn form External Post URL as a query string in the Gravity Form's Confirmation settings. This allows the use of a single script in your theme files to submit different forms to Acton. You'll want to encode the URL using this tool: https://www.url-encode-decode.com/

    <?php 
    if (is_page([5,18,20])) { ?>
    <script type="text/javascript">
    var aoExternalPostURL = "<?php echo $_GET["acton_url"]; ?>";
    function actonSubmit() {
    if (String(window.location).search("%40")>0) {
    var aoUrlParams; var aoQuery = window.location.search.substring(1);
    (window.onpopstate = function () {var e, t = /([^&=]+)=?([^&]*)/g;
    aoUrlParams = {};
    while (e = t.exec(aoQuery)) aoUrlParams[encodeURIComponent(e[1])] = e[2]})();
    for (i in aoUrlParams) {var aoUrlParamsArray = aoUrlParams[i];
    try {document.getElementsByName(i)[0].value = decodeURIComponent(aoUrlParamsArray)}
    catch (err) {}
    };
    var aoIfrm = document.createElement("iframe");
    document.body.appendChild(aoIfrm);
    aoIfrm.setAttribute("id", "ifrm");
    aoIfrm.style.backgroundColor = "transparent";
    aoIfrm.style.border = "none";
    aoIfrm.style.width = "1px";
    aoIfrm.style.height = "1px";
    aoIfrm.src = aoExternalPostURL + "?" + aoQuery;
    };
    };
    window.addEventListener ?
    window.addEventListener("load",actonSubmit,false) :
    window.attachEvent && window.attachEvent("onload",actonSubmit);
    </script>
    <?php } ?>
    0
    Comment actions Permalink

Please sign in to leave a comment.

Looking for more help?