【问题标题】:<FORM> posting to <IFRAME> causes pop up window in IE7 only<FORM> 发布到 <IFRAME> 仅在 IE7 中导致弹出窗口
【发布时间】:2011-06-03 10:44:52
【问题描述】:

我正在使用 jQuery 构建一个 iframe 和表单:

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();

由于某种原因,在 Chrome/Safari/Firefox/IE8+ 中它运行良好,但在 IE7 中它会在弹出窗口中打开表单。

有人知道发生了什么吗?

【问题讨论】:

  • 你为什么要使用target属性?
  • 我在您的回答下方发表了评论。但基本上,动作不是/foobar... 它是http://someotherdomain.com/foobar... 因此ajax 不起作用。

标签: jquery html iframe internet-explorer-7


【解决方案1】:

啊!我想到了!基本上,当您尝试使用 jQuery 向元素添加 name 属性时,IE7 会发疯……您必须在原始字符串中创建名称,如下所示:

iframe = $("<iframe name=\"foo\">");

这是一件多么微妙的事情!希望这有助于防止其他人花费 5 个小时在互联网上搜索答案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多