0
下面的JavaScript导致Internet Explorer,以给予“混合内容”警告: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加载完成检测。这个脚本中的内容会导致混合内容警告?
其原因在http://dean.edwards.name/weblog/2006/06/again/(其中代码来自此处)讨论 – 2011-03-10 04:19:54
我同意Cresent。这与在通过https传送的页面上创建about:blank IFRAME类似。 src必须在https上引用某些内容以确保安全。 – 2011-03-10 04:54:31
为什么你会在这个时代甚至使用这种黑客行为? – Pointy 2011-03-10 05:05:43