0

I have a SmartCapture form created in a cloudpage. Whenever a person fills the form and submit, it will capture information and redirect to a thankyou page (also a cloudpage).

It works well until I embed the form into an external site by <iframe> tag. The information still can be captured but the form doesn't redirect to the target page. Seems like it was blocked

Here is the error I got from the browser console.

smartcapture-formjs.js:516 Uncaught DOMException: Blocked a frame with origin "https://example.com" from accessing a cross-origin frame.
    at success (https://mc.s10.exacttarget.com/CloudPages/lib/smartcapture-formjs.js:516:27)
    at Object.success (https://mc.s10.exacttarget.com/CloudPages/lib/smartcapture-formjs.js:29:16)
    at j (https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js:2:27309)
    at Object.fireWith [as resolveWith] (https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js:2:28122)
    at x (https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js:5:22111)
    at XMLHttpRequest.b (https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js:5:26030)

Disable Same Origin Policy in the external site is not a choice since the page can't be disabled alone.

I was told that I should try to fix the smartcapture page with the function window.parent.postMessage(). To be honest, I have no idea how this can work in this case and where I can put the function..

Anyone who has encountered this issue, please let me know how to handle this. Really appreciate with any help.

1 Answer 1

0

For CORS security issue, this way will help:
Note: I don't have a chance to work with other cases so not sure if this solution can apply to a similar issue. I believe this also depends on the external site.

Go to cloudpage -> click on smart capture and edit HTML. Put the script at the bottom <script> block

const form = document.getElementById('Your smart capture form Id');
form.addEventListener('submit', () => {

// Redirect to the target page after submission
 window.top.location.href = "https://example.com/thankyou"; 

 
// Redirect within the frame
// window.location.href = "https://example.com/thankyou"; 
 });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.