程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> discuz二次開發筆記(二)------跳轉函數運用,discuz二次開發

discuz二次開發筆記(二)------跳轉函數運用,discuz二次開發

編輯:關於PHP編程

discuz二次開發筆記(二)------跳轉函數運用,discuz二次開發


      前幾天在增加修改功能時,突然用到一個提示函數,有點不理解,看了他的由來後果斷做下筆記,感覺這在以後的開發中肯定還是要用的上的。有些地方不是很理解,在以後慢慢糾正、查補。

Htm頁面中用的js跳轉:

$("#lyy_real").click(function(){

    $.post("api/realnamechange.php",

            {uname:$("#uname").val(),uid:$("#uid").val(),realname:$("#realname_lyy").val()},

            function(data){  數據返回執行彈出框,並刷新當前頁面。

                popup.open(data, 'confirm', 'home.php?mod=space&uid='+$("#uid").val());

            }

          );

  })

 

Common.js

var POPMENU = new Object;

var popup = {

         init : function() {

                   var $this = this;

                   $('.popup').each(function(index, obj) {

                            obj = $(obj);

                            var pop = $(obj.attr('href'));

                            if(pop && pop.attr('popup')) {

                                     pop.css({'display':'none'});

                                     obj.on('click', function(e) {

                                               $this.open(pop);

                                     });

                            }

                   });

                   this.maskinit();

         },

         maskinit : function() {

                   var $this = this;

                   $('#mask').off().on('tap', function() {

                            $this.close();

                   });

         },

 

         open : function(pop, type, url) {

                   this.close();

                   this.maskinit();

                   if(typeof pop == 'string') {

                            $('#ntcmsg').remove();

                            if(type == 'alert') {

                                     pop = '<div class="tip"><dt>'+ pop +'</dt><dd><input class="button2" type="button" value="確定" onclick="popup.close();"></dd></div>'

                            } else if(type == 'confirm') {

                                     pop = '<div class="tip"><dt>'+ pop +'</dt><dd><input class="redirect button2" type="button" value="確定" href="'+ url +'"><a href="javascript:;" onclick="popup.close();">取消</a></dd></div>'

                            }

                            $('body').append('<div id="ntcmsg" >'+ pop +'</div>');

                            pop = $('#ntcmsg');

                   }

                   if(POPMENU[pop.attr('id')]) {

                            $('#' + pop.attr('id') + '_popmenu').html(pop.html()).css({'height':pop.height()+'px', 'width':pop.width()+'px'});

                   } else {

                            pop.parent().append('<div class="dialogbox" id="'+ pop.attr('id') +'_popmenu" >'+ pop.html() +'</div>');

                   }

                   var popupobj = $('#' + pop.attr('id') + '_popmenu');

                   var left = (window.innerWidth - popupobj.width()) / 2;

                   var top = (document.documentElement.clientHeight - popupobj.height()) / 2;

                   popupobj.css({'display':'block','position':'fixed','left':left,'top':top,'z-index':120,'opacity':1});

                   $('#mask').css({'display':'block','width':'100%','height':'100%','position':'fixed','top':'0','left':'0','background':'black','opacity':'0.2','z-index':'100'});

                   POPMENU[pop.attr('id')] = pop;

         },

         close : function() {

                   $('#mask').css('display', 'none');

                   $.each(POPMENU, function(index, obj) {

                            $('#' + index + '_popmenu').css('display','none');

                   });

         }

};

上面是popup的定義,下面是他的三種用法:

<!--{if !$_G[uid]}-->

         popup.open('要輸出的提示信息', 'confirm', '點擊確定按鈕後要跳轉的地址'); confirm為彈出提示框的方式,這種方式有確認和取消兩種按鈕,點擊確定後才會跳轉。

<!--{else}-->

         popup.open('要輸出的提示信息', 'alert');alert為彈出提示框的方式,這種方式只有一個確定按鈕,如果下面有跳轉鏈接,不點擊也會在默認時間內跳轉頁面。

<!--{/if}-->

popup.close();隱藏當前窗體

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved