Dynamically creating an iframe in Internet Explorer for remote form submissions
Posted on May 13th, 2008 in General Web Dev, Internet Explorer, JavaScript | 3 Comments »
I’ve been doing a lot of remote iframe work as of late and while creating some functionality that submits a form to a dynamically generated iframe I quickly found that in IE6/7 you cannot target an iframe created with document.createElement('iframe');. You must instead use innerHTML to write out the iframe inside another element.
Oh IE, we will never understand you!
Update: Max commented that you can indeed use document.createEelement and still target iframes in IE, you just need to create them in this way document.createElement('<iframe name="iframeName">');. Still über quirky but slightly better than the innerHTML approach. Kudos Max!