Reputation: 7910
I have a javascript function which dynamically creates an iframe for a form, so the form is sent to iframe. The code works in Chrome, Opera and Firefox, but IE opens new tab when I submit the form.
how to fix this issue?
HTML:
<form id="form1" name="form1" action="/post.php" method="post">
<input type="text" name="foo" value="bar">
<button type="submit" name="send">Send</button>
</form>
Javascript (runs on page load):
var form = document.getElementById("form1");
if(!form.target) {
var frame = document.createElement("iframe");
frame.name = "frame" + Math.random();
frame.id = frame.name;
document.body.appendChild(frame);
form.target = frame.id;
}
Upvotes: 0
Views: 1451