简体   繁体   中英

How to redirect user to a URL after filling out a form from a third party site

I am learning Clickfunnels right now and I encountered a problem. I want to redirect to another url after submitting a form. This form is from a third-party site so I just copy the form code from the site and paste it to my code editor on Clickfunnels.

The following is the code of the form that I copied from the site.

 <div id="MYID" data-so-page="MYIDPAGE" data-height="550" data-style="border: 1px solid #d8d8d8; min-width: 290px; max-width: 900px;" data-psz="00"></div> <script type="text/javascript" src="https://cdn.oncehub.com/mergedjs/so.js"> </script>

Now, what I want to do after submitting the form is to redirect to another url, say "google.com". Do you have any idea how to do it?

Add onclick tag to form

<form id="myform" method="post" onclick="window.open('http://yoururl.com', '_blank');">  
  <input type="submit" class="button4" value="Place Order" >
</form>

or use the function

window.onload=function() {
  document.getElementById("myform").onsubmit=function() {
    window.location("redirectpage.php");
    return false;
  }
}

form

<form id="myform" method="post">  
  <input type="submit" class="button4" value="Place Order" >
</form>

I assume your form is generated by the script that you require from the 3rd party library. Therefore you cannot add anything directly to the form, but you can select it with a dom query amd add a onsubmit event handler.

Something like this maybe: var form = document.querySelector("#MYID > form"); form.addEventListener("submit", e => //redirect here);

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