Share Alert Mod khá đẹp

11 bài đăng
24.11.2017 / 19:04
mad
Bài đăng: 2434
Member
Nhào vô cắn tao đi, tao sợ mày à cắn bừa.
HTML5
  1. </style>
  2. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
  3. <script>
  4. $(function(){
  5. $('a.alert').unbind("click").on("click",function(){
  6. OnAlert($(this).attr('box-title'),$(this).attr('box-content'),$(this).attr('box-action'));
  7. return false;
  8. })
  9. });
  10. function OnAlert(title, content, button){
  11. bt='';
  12. forward='';
  13. if(title && content){
  14. if(button){
  15. vb=JSON.parse(button);
  16. for(i=0;i<vb.length;i++){
  17. if(vb[i]['action']=='close'){
  18. bt+=' <a class="box-button box-close-alert">'+vb[i]['title']+'</a>';
  19. }else{
  20. if(vb[i]['forward']){
  21. forward=' forward="'+vb[i]['forward']+'"';
  22. }else{
  23. forward=' forward="'+vb[i]['action']+'"';
  24. }
  25. bt+=' <a class="box-button box-link no-load" href="'+vb[i]['action']+'"'+forward+'>'+vb[i]['title']+'</a>';
  26. }
  27. }
  28. }else{
  29. bt+=' <a class="box-button box-close-alert">Đã rõ</a>';
  30. }
  31. content='<div class="box-alert"><div class="box-scroll"><div class="box-main"><div class="box-info"><div class="box-title">'+title+'</div><div class="box-content">'+content+'</div><div class="box-submit">'+bt+'</div></div></div></div></div>';
  32. $('body').addClass('alertShow').prepend(content);
  33. $('body .box-info .box-submit a.box-close-alert').unbind("click").on("click",function(){
  34. $('.box-alert').remove();
  35. $('body').removeClass('alertShow');
  36. })
  37. $('body .box-info .box-submit a.box-off-alert').unbind("click").on("click",function(){
  38. $('.box-alert').remove();
  39. $('body').removeClass('alertShow');
  40. setCookie('tb','off','1');
  41. })
  42. $('body .box-info .box-submit a.box-link').unbind("click").on("click",function(){
  43. btn=$(this);
  44. url=btn.attr('forward')?btn.attr('href'):btn.attr('href');
  45. location.href=url;
  46. $('.box-alert').remove();
  47. $('body').removeClass('alertShow');
  48. return false;
  49. })
  50. }
  51. }
  52. function rmAds(){
  53. if($('iframe#AirpushDefaultIframe').length>=0){
  54. $('iframe#AirpushDefaultIframe').remove()
  55. }
  56. setTimeout(function(){rmAds()}, 500);
  57. }
  58. rmAds();
  59. </script>
  60.  
  61. <style>
  62.  
  63. ::-webkit-scrollbar{width: 8px;height: 8px;}
  64. ::-webkit-scrollbar-track{background: #d6d6d6;}
  65. ::-webkit-scrollbar-thumb{border-radius: 10px; background: #fff; border: 1px solid #c6c6c6;}
  66.  
  67. body{
  68. border:1px solid #eee;
  69. color:#00f;margin:0px;
  70. text-align:center;
  71. max-width:100%;
  72. background-color:#FFF;
  73. word-break:break-word;
  74. }
  75.  
  76. body.alertShow{
  77. overflow: hidden;
  78. }
  79.  
  80. .box-alert {
  81. position: fixed;
  82. top: 0px;
  83. left: 0px;
  84. right: 0px;
  85. bottom: 0px;
  86. background: rgba(0, 0, 0, 0.1);
  87. z-index: 1001;
  88. }
  89. .box-scroll{
  90. height: 100%;
  91. overflow: auto;
  92. }
  93. .box-scroll::-webkit-scrollbar-track{
  94. background: transparent;
  95. }
  96. .box-main {
  97. max-width: 500px;
  98. margin: auto;
  99. padding: 10px;
  100. box-sizing: border-box;
  101. }
  102. .box-info{
  103. background: #fff;
  104. border-radius: 4px;
  105. overflow: hidden;
  106. }
  107. .box-title {
  108. padding: 10px;
  109. color: #999;
  110. font-size: 13px;
  111. text-align: center;
  112. }
  113. .box-content{
  114. padding: 10px;
  115. padding-top: 0px;
  116. font-size: 13px;
  117. color: #999;
  118. text-align: left;
  119. }
  120. .box-submit{
  121. border-top: 1px solid #f1f1f1;
  122. padding: 5px;
  123. font-size: 13px;
  124. text-align: right;
  125. }
  126. .box-submit a.box-button{
  127. height: 28px;
  128. display: inline-block;
  129. border: 1px solid;
  130. border-color: #efefef #e7e7e7 #d9d9d9;
  131. font-size: 12px;
  132. line-height: 12px;
  133. color: #333;
  134. text-align: center;
  135. cursor: pointer;
  136. background-color: #fff;
  137. position: relative;
  138. box-sizing: border-box;
  139. white-space: nowrap;
  140. border-radius: 4px;
  141. padding: 7px 16px;
  142. box-shadow: 0px 1px 0px 0px #f3f3f3;
  143. outline: 0px;
  144. }
  145. .box-submit a.box-button:hover{
  146. text-shadow: none;
  147. font-weight: normal;
  148. }

cái này các bạn thêm vào đầu CSS của phong cách và màu sắc trang web

cách sử dụng

Đối với link thông báo thì

HTML5
  1. <a href="" class="alert" data-title="Đăng xuất" box-content="Bạn có muốn đăng xuất?" box-action='[{"title":"Đăng xuất","action":"/main.php?id=logout"},{"title":"Tôi muốn ở lại","action":"close"}]'>Đăng xuát</a>

data-title Là tiêu đề của alert

data-content nội dung của alert

data-action đây là các nút thực hiện hành động của alert

title tiêu đề của nút

action hành động của nút được chuyển đến link hoặc đóng của sổ alert(đặt là close)

box-action mặc đình là json(vd này tôi dùng 3 nút cho anh em dễ hiểu)

TEXT
  1. [{"title":"Đăng nhập","action":"main.php?id=log"},{"title":"Đăng ký","action":"main.php?id=reg"},{"title":"Đóng","action":"close"}]

[b][Ví dụ về box thông báo hoặc thông tin dùng script để chạy/b]

- mặc định

<script>

OnAlert('Thông báo','Chào mừng bạn đến với website! Hãy tham gia giao lưu học hỏi với chúng tôi');

</script>

- Tùy chỉnh

<script>

action='[{"title":"Đăng nhập","action":"main.php?id=log"},{"title":"Đăng ký","action":"main.php?id=reg"},{"title":"Đóng","action":"close"}]';

OnAlert('Thông báo','Chào mừng bạn đến với website! Hãy tham gia giao lưu học hỏi với chúng tôi',action);

</script>

Chúc các man thành công

Một số ảnh

[IMAGE]
[IMAGE]
[IMAGE]
24.11.2017 / 19:33
manhhung
Bài đăng: 458
Member

Hóng alert giống love.wap.mu

24.11.2017 / 19:50
mad
Bài đăng: 2434
Member
Nhào vô cắn tao đi, tao sợ mày à cắn bừa.

Man lên mạng tìm gdialog là có nhe

24.11.2017 / 19:52
manhhung
Bài đăng: 458
Member

24.11.2017 / 19:53
manhhung
Bài đăng: 458
Member

Không biết dùng. Mà nhìn cái gdialog vó vẻ nặng

24.11.2017 / 19:55
mad
Bài đăng: 2434
Member
Nhào vô cắn tao đi, tao sợ mày à cắn bừa.

Vậy dùng alert này nhé khá ổn có sẵn xóa qc wapego

24.11.2017 / 20:00
manhhung
Bài đăng: 458
Member

Có demo k giờ tôi dùng wap4

24.11.2017 / 20:40
Manhkhuyen
Bài đăng: 533
Member
merry christmas

Chuẩn :) đang cần.

27.11.2017 / 08:24
VinaDP
Bài đăng: 627
Member

Ngon đấy :)

27.11.2017 / 09:44
mad
Bài đăng: 2434
Member
Nhào vô cắn tao đi, tao sợ mày à cắn bừa.

data-title="Đăng xuất" => box-title="Đăng xuất" nhé viết nhầm chỗ đó