I am trying to get post a form to a hidden, dynamically inserted iframe, but in Internet Explorer the form submission opens in a new window.
var iframe = document.createElement('iframe');
iframe.name = 'hidden_iframe';
iframe.className = 'NotVisible';
iframe.id = 'hidden_iframe';
document.body.appendChild(iframe);
var my_form = document.getElementById('my_form');
my_form.target = 'hidden_iframe';
This works in Firefox but not Internet Explorer.
Apparently you need to include the name in the call to createElement. This works in IE and causes an exception in standards compliant browsers. We get:
var iframe;
try {
iframe = document.createElement('<iframe name="hidden_iframe">');
} catch (ex) {
iframe = document.createElement('iframe');
iframe.name='hidden_iframe';
}
iframe.className = 'NotVisible';
iframe.id = 'hidden_iframe';
document.body.appendChild(iframe);
var my_form = document.getElementById('my_form');
my_form.target = 'hidden_iframe';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With