comet_iframe.js
1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var comet = {
connection: false,
iframediv: false,
timer: 0,
initialize: function (url) {
if (!-[1,]) {
// For IE browsers
comet.connection = new ActiveXObject("htmlfile");
comet.connection.open();
comet.connection.write("<html>");
comet.connection.write("<script>document.domain = '" + document.domain + "'");
comet.connection.write("</html>");
comet.connection.close();
comet.iframediv = comet.connection.createElement("div");
comet.connection.appendChild(comet.iframediv);
comet.connection.parentWindow.comet = comet;
comet.iframediv.innerHTML = "<iframe id='comet_iframe' name='comet_iframe' src='"+url+"'></iframe>";
var comet_iframe = comet.connection.getElementById("comet_iframe");
comet.timer = window.setInterval(function() {
if (comet_iframe.readyState === "complete") {
comet_iframe.src = comet_iframe.src;
}
}, 1000 * 65);
} else {
comet.connection = document.createElement('iframe');
comet.connection.onload = function () {
comet.connection.src = comet.connection.src;
}
comet.connection.setAttribute('id', 'comet_iframe');
comet.connection.setAttribute('src', url);
comet.connection.style.display = "none";
document.body.appendChild(comet.connection);
}
},
onUnload: function () {
if (comet.connection) {
comet.connection = false; // release the iframe to prevent problems with IE when reloading the page
}
}
}