Table of Contents
discuz二次开发笔记(二)------跳转函数运用,discuz二次开发
Home php教程 php手册 discuz二次开发笔记(二)------跳转函数运用,discuz二次开发

discuz二次开发笔记(二)------跳转函数运用,discuz二次开发

Jun 13, 2016 am 09:06 AM
discuz two Secondary development function notes Jump use

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 = '

'+ pop +'
'

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

                                     pop = '

'+ pop +'
取消
'

                            }

                            $('body').append('

');

                            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('

'+ pop.html() +'
');

                   }

                   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的定义,下面是他的三种用法:

         popup.open('要输出的提示信息', 'confirm', '点击确定按钮后要跳转的地址'); confirm为弹出提示框的方式,这种方式有确认和取消两种按钮,点击确定后才会跳转。

         popup.open('要输出的提示信息', 'alert');alert为弹出提示框的方式,这种方式只有一个确定按钮,如果下面有跳转链接,不点击也会在默认时间内跳转页面。

popup.close();隐藏当前窗体

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Tips for dynamically creating new functions in golang functions Tips for dynamically creating new functions in golang functions Apr 25, 2024 pm 02:39 PM

Tips for dynamically creating new functions in golang functions

Considerations for parameter order in C++ function naming Considerations for parameter order in C++ function naming Apr 24, 2024 pm 04:21 PM

Considerations for parameter order in C++ function naming

How to write efficient and maintainable functions in Java? How to write efficient and maintainable functions in Java? Apr 24, 2024 am 11:33 AM

How to write efficient and maintainable functions in Java?

Comparison of the advantages and disadvantages of C++ function default parameters and variable parameters Comparison of the advantages and disadvantages of C++ function default parameters and variable parameters Apr 21, 2024 am 10:21 AM

Comparison of the advantages and disadvantages of C++ function default parameters and variable parameters

Complete collection of excel function formulas Complete collection of excel function formulas May 07, 2024 pm 12:04 PM

Complete collection of excel function formulas

What are the benefits of C++ functions returning reference types? What are the benefits of C++ functions returning reference types? Apr 20, 2024 pm 09:12 PM

What are the benefits of C++ functions returning reference types?

What is the difference between custom PHP functions and predefined functions? What is the difference between custom PHP functions and predefined functions? Apr 22, 2024 pm 02:21 PM

What is the difference between custom PHP functions and predefined functions?

C++ Function Exception Advanced: Customized Error Handling C++ Function Exception Advanced: Customized Error Handling May 01, 2024 pm 06:39 PM

C++ Function Exception Advanced: Customized Error Handling

See all articles