Chinaunix首页 | 论坛 | 博客
  • 博客访问: 306950
  • 博文数量: 128
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1611
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-19 11:49
文章分类

全部博文(128)

文章存档

2018年(2)

2016年(2)

2014年(10)

2013年(114)

我的朋友

分类: HTML5

2013-09-09 11:36:41


点击(此处)折叠或打开

  1. var popupStatus = 0;
  2. //loading popup with jQuery magic!
  3. function loadPopup(){
  4. //loads popup only if it is disabled
  5. if(popupStatus==0){
  6. $("#backgroundPopup").css({
  7. "opacity": "0.7"
  8. });
  9. $("#backgroundPopup").fadeIn("slow");
  10. $("#popupContact").fadeIn("slow");
  11. popupStatus = 1;
  12. }
  13. }
  14. //disabling popup with jQuery magic!
  15. function disablePopup(){
  16. //disables popup only if it is enabled
  17. if(popupStatus==1){
  18. $("#backgroundPopup").fadeOut("slow");
  19. $("#popupContact").fadeOut("slow");
  20. popupStatus = 0;
  21. }
  22. }
  23. //centering popup
  24. function centerPopup(){
  25. //request data for centering
  26. var browser=navigator.userAgent;
  27. var windowWidth = document.documentElement.clientWidth;
  28. var windowHeight = document.documentElement.clientHeight;
  29. var stop="";
  30. var sleft="";
  31. if(browser.indexOf('Chrome')!=-1){
  32. stop=document.body.scrollTop;
  33. sleft=document.body.scrollLeft;
  34. }
  35. else{
  36. stop=document.documentElement.scrollTop;
  37. sleft=document.documentElement.scrollLeft;
  38. }
  39. // windowWidth+=document.body.scrollLeft;
  40. // windowHeight+=document.body.scrollTop;
  41. var popupHeight = $("#popupContact").height();
  42. var popupWidth = $("#popupContact").width();
  43. //centering
  44. $("#popupContact").css({
  45. "position": "absolute",
  46. "top": windowHeight/2-popupHeight/2+stop,
  47. "left": windowWidth/2-popupWidth/2+sleft
  48. });
  49. //only need force for IE6
  50. //背景色
  51. $("#backgroundPopup").css({
  52. "height": windowHeight
  53. });
  54. }
  55. //调用弹出框事件
  56. function bb(str){
  57. $("#download").show();
  58. centerPopup();
  59. loadPopup();
  60. //CLOSING POPUP
  61. //Click the x event!
  62. $("#popupContactClose").click(function(){
  63. disablePopup();
  64. });
  65. //http://www.unitymanual.com unity3d
  66. //http://www.unitymanual.com/sitemap.xml
  67. //Click out event!,点击背景事件
  68. $("#backgroundPopup").click(function(){
  69. disablePopup();
  70. });
  71. //Press Escape event!
  72. $(document).keypress(function(e){
  73. if(e.keyCode==27 && popupStatus==1){
  74. disablePopup();
  75. }
  76. });
  77. }



点击(此处)折叠或打开

  1. <div id="download" style="display: none;">
  2. <div id="popupContact">

  3. </div>
  4. <div id="backgroundPopup"></div>
  5. </div>
  6. </div>

阅读(474) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~