Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type=”text/javascript“>
- var comet = {
- connection : false,
- iframediv : false,
- initialize: function() {
- if (navigator.appVersion.indexOf(“MSIE”) != -1) {
- // Для IE
- 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’ src=’./backend.php’></iframe>“;
- } else {
- // Для других браузеров (Firefox…)
- comet.connection = document.createElement(‘iframe’);
- comet.connection.setAttribute(‘id’, ‘comet_iframe’);
- with (comet.connection.style) {
- left = top = “-100px”;
- height = width = “1px”;
- visibility = “hidden”;
- display = ‘none’;
- }
- comet.iframediv = document.createElement(‘iframe’);
- comet.iframediv.setAttribute(’src’, ‘./backend.php’);
- comet.connection.appendChild(comet.iframediv);
- document.body.appendChild(comet.connection);
- }
- },
- // эта функция вызывается из backend.php
- printServerTime: function (time) {
- $(‘content’).innerHTML = time;
- },
- onUnload: function() {
- if (comet.connection) {
- comet.connection = false; // удаление iframe для предотвращения вероятных проблем при перезагрузки страницы в IE
- }
- }
- }
- Event.observe(window, “load”, comet.initialize);
- Event.observe(window, “unload”, comet.onUnload);
- </script>
Add Comment
Please, Sign In to add comment