What I’m trying to do:
I would like to have an appointment request form on my Wordpress website that redirects to a confirmation page once the form is complete. On my website, I have a code module where I can input HTML. I added the embedding code for my Anvil form:
<script src="https://anvil.works/embed.js" async></script>
<iframe style="width:100%;" src="https://*.anvil.app/*"></iframe>
In the Anvil app, I have a line like this:
anvil.js.window.top.location.href = 'https://www.google.com/'
which gets triggered when you hit the “Submit” button. This works when I run the Anvil app by itself. However, if I embed it into the IFrame, I get an error like:
`ExternalError: SecurityError: Blocked a frame with origin "*.anvil.app" from accessing a cross-origin frame.`
which probably makes sense for security reasons. However, I need a way to work around this. Does anyone have any ideas?
What I’ve tried and what’s not working:
I have tried a number of things. One of the most promising seemed to be the sandboxing concept. For example, doing something like:
<script src="https://anvil.works/embed.js" async></script>
<iframe style="width:100%;" src="https://*.anvil.app/*" sandbox="allow-same-origin allow-top-navigation allow-scripts allow-forms"></iframe>
to the IFrame. However, I still get the same error and cannot access the browser navigation.
In other places, people talk about postMessage a lot, but I have no idea how to apply it here.
Some other relevant links I have explored: