【问题标题】:Internet Explorer: Mixed Content Delivery WarningInternet Explorer:混合内容交付警告
【发布时间】:2011-03-10 03:48:41
【问题描述】:

以下 javascript 导致 Internet Explorer 发出“混合内容”警告:

function init() {
  // quit if this function has already been called
  if (arguments.callee.done) return;

  // flag this function so we don't do the same thing twice
  arguments.callee.done = true;

  // kill the timer
  if (_timer) clearInterval(_timer);

  // do stuff
};

/* for Mozilla/Opera9 */
if (document.addEventListener) {
  document.addEventListener("DOMContentLoaded", init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
  document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
  var script = document.getElementById("__ie_onload");
  script.onreadystatechange = function() {
    if (this.readyState == "complete") {
      init(); // call the onload handler
    }
  };
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
  var _timer = setInterval(function() {
    if (/loaded|complete/.test(document.readyState)) {
      init(); // call the onload handler
    }
  }, 10);
}

/* for other browsers */
window.onload = init;

用于检测 DOM 何时完成加载。此脚本中的什么内容会导致混合内容警告?

【问题讨论】:

  • 其原因在dean.edwards.name/weblog/2006/06/again 讨论(此代码来自哪里)
  • 我同意 Cresent。这类似于在通过 https 传递的页面上创建 about:blank IFRAME。 src 必须引用 https 上的某些内容以确保安全。
  • 在这个时代,你为什么还要使用这种技巧?
  • 我正在使用 Magento GO 托管解决方案,上传 jQuery 库会导致 Magento 模板的功能停止工作(大部分 ui 交互性/等等)。有没有更好的方法来检查DOM 使用不同的方法加载了 jQuery?
  • 已解决 - 对于任何试图在 Magento GO 模板中使用 jQuery 库的人,您必须在 jQuery 库的末尾调用 jQuery.noConflict()。在以后的 js 文件中调用它不会成功:)

标签: javascript internet-explorer dom ssl https


【解决方案1】:

我的猜测是创建了一个不使用 HTTPS 的脚本标签。

【讨论】:

  • 我不是 100% 确定,但我不认为 IE 坚持在主页是“https”时,脚本、样式表和图像都是“https”。但是,它确实坚持&lt;iframe&gt; 来源。
  • IE(和所有其他浏览器)确实要求所有脚本、样式表、图像和 iframe 都是 https 如果正在加载的页面是 https。
猜你喜欢
  • 2016-06-22
  • 2017-02-04
  • 1970-01-01
  • 1970-01-01
  • 2018-03-19
  • 2013-04-03
  • 1970-01-01
  • 2018-11-08
  • 1970-01-01
相关资源
最近更新 更多