【问题标题】:Stop all jQuery before changing iFrame在更改 iFrame 之前停止所有 jQuery
【发布时间】:2015-12-08 22:00:42
【问题描述】:

我有一个带有上一个和下一个按钮(以及 iFrame 之外的其他控件)的脚本,每次单击按钮时都会重新填充一个 iFrame。这很好用,除非我在 iFrame 中淡化图像并在其仍在处理过程中更改内容。我遇到的问题是在 IE 10 和 11 中。在非 IE 浏览器中似乎很好。

我已经精简了代码,以便于查看发生了什么。我基本上是从 iFrame 外部淡化图像,例如:

var iframe = $('#iframe').contents();
$('#imageFading',iframe).fadeTo(750,1.0);

我将 iFrame 内容更改为:

var html = "Some HTML Content here";
var iframe = $('#iFrame').get(0);
iframe = (iframe.contentWindow) ? iframe.contentWindow : (iframe.contentDocument.document) ? iframe.contentDocument.document : iframe.contentDocument;
iframe.document.open();
iframe.document.write(html);
iframe.document.close();

如果 iFrame 内容在图像仍然褪色时被更改,我会收到错误消息:

SCRIPT70: Permission denied
File: jquery.min.js, Line: 4, Column: 928

此错误一直在控制台中输出,直到我刷新或关闭页面。我正在使用 jQuery 1.11.2。

当我使用未压缩版本时,它的第 6999 行,即:

} else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {

我尝试将fadeTo 放入try/catch 并使用jQuery 的clearQueue()。

【问题讨论】:

  • jsFile: jquery.min.js, Line: 4, Column: 928 是什么?在更改 iframe 的内容之前尝试删除元素?
  • 我已经从未压缩版本中放入了上面行的详细信息。在使用 jQuery 的删除和使用 html 函数覆盖之前,我曾尝试删除特定元素和所有元素。没有运气。
  • 在调整iframe内容之前尝试.stop(true, true),参见api.jquery.com/stop/#stop-clearQueue-jumpToEnd
  • 谢谢,刚刚发现确实有效。
  • 如果你发一个我会给你答案。

标签: jquery iframe permission-denied


【解决方案1】:

在调整iframe 内容之前尝试.stop(true, true)

【讨论】:

    【解决方案2】:

    在重新加载 iframe 之前,我最终通过使用 jQuery 的 stop 函数使其工作。

    $('#imageFading',iframe).stop();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多