Reputation: 4853
I'm construction a iframe and form with jQuery as such:
iframe = $("<iframe>", {name : "foo"});
form = $("<form>", {
target : $iframe.attr("name"),
action : "/foobar",
method : "POST"
}).append($("<input>", {
type : "submit",
name : "amifully",
value : "dressed"
}).hide());
$("body").append(iframe).append(form);
form.submit();
For some reason, in Chrome/Safari/Firefox/IE8+ it works great but in IE7 it opens the form in a pop up window.
Anyone have any idea what's going on?
Upvotes: 2
Views: 2392
Reputation: 4853
Ahhh! I figured it out! Basically, IE7 freaks out when you try to add name
attributes to elements with jQuery... you have to create the name in the raw string as such:
iframe = $("<iframe name=\"foo\">");
It was such a subtle thing! Hope this helps prevent someone else from spending 5 hours scouring the internet for an answer.
Upvotes: 6