PopWinJScript.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. document.writeln(" <div id=\"floatBox\" class=\"floatBox\">");
  2. document.writeln(" <div class=\"title\">");
  3. document.writeln(" <h4>");
  4. document.writeln(" 通知");
  5. document.writeln(" <\/h4>");
  6. document.writeln(" <h5>");
  7. document.writeln(" <img id=\"ajaxloadimg\" style=\"display: none;\" alt=\"ajax-loading\" src=\"\/Content\/js_pop\/PopWin\/image\/popwin_loading.gif\" \/><\/h5>");
  8. document.writeln(" <span>关闭<\/span><\/div>");
  9. document.writeln(" <div class=\"content\">");
  10. document.writeln(" <ul>");
  11. //document.writeln("<fieldset><legendname>待审核信息<\/legendname>");
  12. //document.writeln(" <li>张玉海提交&nbsp;&nbsp;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
  13. //document.writeln(" <button id='popbtn' onclick=\"switchWindow('4|2|1|3|5','\/ConfigDate\/left_navigation.aspx?ajaxwin=ajaxwin',null,null);\">");
  14. //document.writeln(" 查看<\/button><\/li>");
  15. //document.writeln(" <li>张玉海提交&nbsp;&nbsp;XXXXXXXXXXXXXXXXXXXdddddddddddddddddddXXXXXXXXXXXXXXXXXXXXXXX");
  16. //document.writeln(" <button id='popbtn' onclick=\"switchWindow('4|2|1|3|5','\/ConfigDate\/left_navigation.aspx?ajaxwin=ajaxwin',null,null);\">");
  17. //document.writeln(" 查看<\/button><\/li>");
  18. //document.writeln(" <li>张玉海提交&nbsp;&nbsp;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
  19. //document.writeln(" <button id='popbtn' onclick=\"switchWindow('4|2|1|3|5','\/ConfigDate\/left_navigation.aspx?ajaxwin=ajaxwin',null,null);\">");
  20. //document.writeln(" 查看<\/button><\/li>");
  21. //document.writeln(" <li>张玉海提交&nbsp;&nbsp;XXXXXXXXXXXXXXXXXddddddddddddddddddddddXXXXXXXXXXXXXXXXXXXXXXXXX");
  22. //document.writeln(" <button id='popbtn' onclick=\"switchWindow('4|2|1|3|5','\/ConfigDate\/left_navigation.aspx?ajaxwin=ajaxwin',null,null);\">");
  23. //document.writeln(" 查看<\/button><\/li>");
  24. //document.writeln(" <li>张玉海提交&nbsp;&nbsp;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
  25. //document.writeln(" <button id='popbtn' onclick=\"switchWindow('4|2|1|3|5','\/ConfigDate\/left_navigation.aspx?ajaxwin=ajaxwin',null,null);\">");
  26. //document.writeln(" 查看<\/button><\/li>");
  27. //document.writeln(" <li>张玉海提交&nbsp;&nbsp;XXXXXXXXXXXXXXXXXdddddddddddddddddXXXXXXXXXXXXXXXXXXXXXXXXX");
  28. //document.writeln(" <button id='popbtn' onclick=\"switchWindow('4|2|1|3|5','\/ConfigDate\/left_navigation.aspx?ajaxwin=ajaxwin',null,null);\">");
  29. //document.writeln(" 查看<\/button><\/li>");
  30. //document.writeln(" <li>张玉海提交&nbsp;&nbsp;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
  31. //document.writeln(" <button id='popbtn' onclick=\"switchWindow('4|2|1|3|5','\/ConfigDate\/left_navigation.aspx?ajaxwin=ajaxwin',null,null);\">");
  32. //document.writeln(" 查看<\/button><\/li>");
  33. //document.writeln(" <li>张玉海提交&nbsp;&nbsp;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
  34. //document.writeln(" <button id='popbtn' onclick=\"switchWindow('4|2|1|3|5','\/ConfigDate\/left_navigation.aspx?ajaxwin=ajaxwin',null,null);\">");
  35. //document.writeln(" 查看<\/button><\/li>");
  36. //document.writeln(" <li>张玉海提交&nbsp;&nbsp;XXXXXXXXXXXXXXXXXXXXddddddddddddddddddddddddddddddddddXXXXXXXXXXXXXXXXXXXXXX");
  37. //document.writeln(" <button id='popbtn' onclick=\"switchWindow('4|2|1|3|5','\/ConfigDate\/left_navigation.aspx?ajaxwin=ajaxwin',null,null);\">");
  38. //document.writeln(" 查看<\/button><\/li>");
  39. //document.writeln(" <li>张玉海提交&nbsp;&nbsp;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
  40. //document.writeln(" <button id='popbtn' onclick=\"switchWindow('4|2|1|3|5','\/ConfigDate\/left_navigation.aspx?ajaxwin=ajaxwin',null,null);\">");
  41. //document.writeln(" 查看<\/button><\/li>");
  42. //document.writeln("<\/fieldset>");
  43. document.writeln(" <\/ul>");
  44. document.writeln(" <\/div>");
  45. document.writeln(" <\/div>");
  46. //---------------------------------------------------
  47. /*
  48. <link rel="stylesheet" type="text/css" href="/PopWin/PopWinStyleSheet.css" />
  49. <script type="text/javascript" src="/js/jquery-1.4.1.min.js"></script>
  50. <script type="text/javascript" src="/js/jquery.cookie.js"></script>
  51. <script type="text/javascript"> var clearcookie = true;</script><%--默认主页需要加上这一句,其余页面不加--%>
  52. <script type="text/javascript" src="/PopWin/PopWinJScript.js"></script>
  53. */
  54. var cookie;//全局
  55. var ajaxflag = true;//是否开启发送功能
  56. //关闭层
  57. var closeDiv = function () {
  58. $("#floatBox .title span").text("展开").attr("title", "展开");
  59. setCookie('close');
  60. getCookie();
  61. $("#floatBox").hide();
  62. //$("#floatBox").animate({
  63. // height: '30px'
  64. //}, 500, 'linear', function () { $("#floatBox .content").hide(); });
  65. }
  66. //展开层,同时发送ajax请求
  67. var openDiv = function () {
  68. //ajaxLoad();
  69. $("#floatBox .title span").text("关闭").attr("title", "关闭");
  70. setCookie('open');
  71. getCookie();
  72. $("#floatBox").show();
  73. $("#floatBox").animate({
  74. height: '200px'
  75. }, 500, 'linear', function () { $("#floatBox .content").show(); });
  76. }
  77. //开启定不能用这个函数
  78. function divHidden1() {
  79. $("#floatBox .title span").toggle(openDiv, closeDiv)
  80. }
  81. //function divHidden2() {
  82. // $("#floatBox .title span").toggle(closeDiv, openDiv)
  83. //}
  84. //手动实现上面的层展开关闭的交互操作
  85. function divHidden() {
  86. $("#floatBox .title span").click(function () {
  87. if (cookie == null || cookie == "close") {
  88. openDiv();
  89. }
  90. else {
  91. closeDiv();
  92. $.ajax({
  93. url: "/Sys/Home/UpdateAlarmInfo",
  94. type: 'get',
  95. success: function (data, textStatus) {
  96. },
  97. });
  98. }
  99. });
  100. }
  101. //读取cookie
  102. function getCookie() {
  103. cookie = $.cookie('DIVSETING');
  104. }
  105. //设置cookie
  106. function setCookie(seting) {
  107. var date = new Date();
  108. date.setTime(date.getTime() + (30 * 24 * 60 * 60 * 1000));
  109. $.cookie('DIVSETING', seting, { path: '/', expires: date });
  110. return false;
  111. }
  112. //初始窗口状态
  113. function setDivState() {
  114. if (cookie == null || cookie == "close") {
  115. $("#floatBox .title span").text("展开").attr("title", "展开");
  116. } else {
  117. openDiv();
  118. }
  119. divHidden();
  120. }
  121. //设置目标窗口url
  122. function switchWindow(_top, _left, _right, _middle) {
  123. var top = _top.split("|");
  124. self.top.frames[0].ShowDiv(top[0], top[1], top[2], top[3], top[4]);
  125. self.top.frames[1].location.href = _left;
  126. //self.top.frames[3].location.href = _middle;
  127. }
  128. //打开窗口
  129. function setAjaxWinState() {
  130. if (cookie == null || cookie == "close") {
  131. openDiv();
  132. } else {
  133. ajaxLoad();
  134. }
  135. }
  136. //异步获取数据
  137. function getDataByAjaxNew() {
  138. if (ajaxflag) {
  139. ajaxLoad()
  140. }
  141. }
  142. function getDataByAjax() {
  143. if (ajaxflag) {
  144. setAjaxWinState()
  145. }
  146. }
  147. function ajaxLoad() {
  148. $.ajax({
  149. url: "/Sys/Home/GetAlarmInfo",
  150. type: 'get',
  151. beforeSend: function (XMLHttpRequest) {
  152. //$('#ajaxloadimg').show();
  153. },
  154. success: function (data, textStatus) {
  155. if (data == null) {
  156. closeDiv();
  157. }
  158. else {
  159. if (data == "") {
  160. closeDiv();
  161. }
  162. else {
  163. openDiv();
  164. $('.floatBox .content ul').html("");
  165. $('.floatBox .content ul').append(data);
  166. }
  167. }
  168. },
  169. error: function (XMLHttpRequest, textStatus) {
  170. $('.floatBox .content ul').html("");
  171. $('.floatBox .content ul').text(XMLHttpRequest.responseText);
  172. },
  173. complete: function (XMLHttpRequest, textStatus) {
  174. $('#ajaxloadimg').hide();
  175. }
  176. });
  177. }
  178. $(function () {
  179. //ajaxflag = false;//是否开启定时获取数据
  180. getCookie();
  181. if (typeof (clearcookie) != "undefined" && clearcookie == true) {
  182. openDiv();
  183. divHidden();
  184. } else {
  185. setDivState();
  186. }
  187. setInterval("getDataByAjaxNew();", 1000);
  188. });