Guest User

Untitled

a guest
Apr 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. <script type=”text/javascript“>
  2. var comet = {
  3. connection : false,
  4. iframediv : false,
  5.  
  6. initialize: function() {
  7. if (navigator.appVersion.indexOf(“MSIE”) != -1) {
  8.  
  9. // Для IE
  10.  
  11. comet.connection = new ActiveXObject(”htmlfile”);
  12. comet.connection.open();
  13. comet.connection.write(”<html>”);
  14. comet.connection.write(”<script>document.domain = ‘”+document.domain+”‘”);
  15. comet.connection.write(“</html>”);
  16. comet.connection.close();
  17. comet.iframediv = comet.connection.createElement(“div”);
  18. comet.connection.appendChild(comet.iframediv);
  19. comet.connection.parentWindow.comet = comet;
  20. comet.iframediv.innerHTML = “<iframe id=’comet_iframe’ src=’./backend.php’></iframe>“;
  21.  
  22. } else {
  23.  
  24. // Для других браузеров (Firefox…)
  25. comet.connection = document.createElement(‘iframe’);
  26. comet.connection.setAttribute(‘id’, ‘comet_iframe’);
  27. with (comet.connection.style) {
  28. left = top = “-100px”;
  29. height = width = “1px”;
  30. visibility = “hidden”;
  31. display = ‘none’;
  32. }
  33. comet.iframediv = document.createElement(‘iframe’);
  34. comet.iframediv.setAttribute(’src’, ‘./backend.php’);
  35. comet.connection.appendChild(comet.iframediv);
  36. document.body.appendChild(comet.connection);
  37.  
  38. }
  39. },
  40.  
  41. // эта функция вызывается из backend.php
  42. printServerTime: function (time) {
  43. $(‘content’).innerHTML = time;
  44. },
  45.  
  46. onUnload: function() {
  47. if (comet.connection) {
  48. comet.connection = false; // удаление iframe для предотвращения вероятных проблем при перезагрузки страницы в IE
  49. }
  50. }
  51. }
  52. Event.observe(window, “load”, comet.initialize);
  53. Event.observe(window, “unload”, comet.onUnload);
  54.  
  55. </script>
Add Comment
Please, Sign In to add comment