Aar*_*ter 2 html iframe jquery internet-explorer-7
我用jQuery构造一个iframe和form:
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();
Run Code Online (Sandbox Code Playgroud)
出于某种原因,在Chrome/Safari/Firefox/IE8 +中,它运行良好,但在IE7中,它会在弹出窗口中打开表单.
任何人都知道发生了什么事吗?
唉唉!我想到了!基本上,当您尝试name使用jQuery向元素添加属性时,IE7会吓坏你......你必须在原始字符串中创建名称:
iframe = $("<iframe name=\"foo\">");
Run Code Online (Sandbox Code Playgroud)
这是一件微妙的事情!希望这有助于防止其他人花5个小时在互联网上搜索答案.
| 归档时间: |
|
| 查看次数: |
2282 次 |
| 最近记录: |