Need form submission to break out of an iFrame?
I’m kind of posting this for my own memory.
From time to time I come across these situations where there is a simple answer but I simply have not done before or can’t remember.
So, here was the scenario:
I had an iFrame on a website that loaded some dynamic content and did some processing in the background (and yes, it had to be done this using, using 3rd party software API)…. this iFrame then presented a form with a couple of options.
What I found out after creating the form and functionality to handle the “stuff” in the iFrame was that the form submission and the next page load were being presented within the iFrame… which maybe I could do a little work around, but it wasn’t the best or cleanest way to accomplish what was desired.
So, after a little help from “my friend Google“, I found that it was nice and easy. I added an onclick attribute with my submit button… and voila it worked!
Here’s an example of what worked:
<input type=”submit” value=” Freedom! ” onclick=”this.form.target=’_top'” />