redirect_to out of an iframe

2019-07-18 16:18发布

问题:

i have a rails app which has a form that renders in an iframe, and from the create action i would like to redirect_to out of the iframe and re-render the whole page rather than in the iframe.

i was curious what ideas are out there to accomplish this.

回答1:

You can do it! you have to replace the redirect_to with:

render :text => "<script>parent.location.href='/cms';</script>"


回答2:

I'm pretty sure that the redirect_to method won't be able to be aware of the iframe you're in and will instead have to be done through some javascript

You might be able to submit your form, via javascript, to the parent window by serializing the form fields.



回答3:

window.location.reload() after submitting your form via AJAX?