• ThinkPHP跳转与重定向的区别在哪里


    跳转:

    浏览器认为 : 当前 URL 请求成功 , 重新请求新的 URL .

    浏览器会记录当前的 URL 和新的 URL 在请求历史记录中.

    回退, 是可以回退到 , 当前的 URL 上的 . ( 无论 success, 和 error都是一样)

    语法实现:在浏览器层面, 修改浏览器的 location .href 来实现的 :location.href=href;

    重定向:

    浏览器认为 , 当前的 URL 无效 , 被重新定位到新的 URL 上 .

    浏览器不会记录当前的 URL 到历史记录中 ,

    不能回退到当前的 URL 中 .

    语法实现, 都是服务器向浏览器发出重定向响应指令 ,

    通过响应头:

    header('Location:'. URL), 立即重定向到某个 URL

    header('Refresh: ')

    First, imagine you're working in front-end development. You have a button with the ID attribute of command-button , and when the user clicks on it, you want to display an alert dialog.

    Using jQuery , you can implement this functionality like this:

    (function( $ ) {
    'use strict';
    // jQuery's DOM-ready event-handler
    $(function() {
    /**
    * Listen for the 'click' event on the button identified
    * with the 'command-button' ID attribute.

    * When the user clicks on it, display an alert dialog.
    */
    $( '#command-button' ).bind( 'click', function( evt ) {alert( 'You clicked the button.' );
    });
    });
    })( jQuery );

    The comments in the code above should explain exactly what's happening. In short, the browser raises an event when the user clicks on a button. When that happens, our code listens for the event and then responds by displaying a dialog.

    Of course, other libraries, frameworks, or vanilla JavaScript afford this same functionality. The purpose of showing this within jQuery is because it's one of the most common JavaScript libraries, and because it's also what's bundled with WordPress.

    Using WordPress

    The implementation of this pattern doesn't necessarily look the same across all programming languages or paradigms. This often depends on the APIs that the framework, foundation, or application provide.

    In WordPress, registering our own code with an event that fires is a bit different. For example, let's say that you're working with the administration pages in WordPress and you want to add a new submenu item to the Settings menu. We'll call it Tuts+ Options .

    To do this, we'd add the following code to our functions.php file or our plugin or whatever type of project on which we're focused:

    <?php
    add_action( 'admin_menu', 'tutsplus_admin_menu' );
    /**
    * Adds a 'Tuts+ Options' submenu to the 'Settings'
    * menu in the WordPress administration menu.
    */
    function tutsplus_admin_menu() {
    add_submenu_page(
    'options-general.php',
    'tutsplus-admin-menu',
    'Tuts+ Options',
    'manage_options',
    'tutsplus-admin-menu-top',
    'tutsplus_admin_options'
    );
    }

  • 相关阅读:
    洛谷P2798 爆弹虐场
    洛谷P1164 小A点菜(01背包求方案数)
    洛谷P1312 Mayan游戏
    洛谷P1514 引水入城
    2017-10-12 NOIP模拟赛
    洛谷P1038 神经网络
    洛谷P1607 [USACO09FEB]庙会班车Fair Shuttle
    洛谷P1378 油滴扩展
    Ionic+Angular实现中英国际化(附代码下载)
    Ionic+Angular+Express实现前后端交互使用HttpClient发送get请求数据并加载显示(附代码下载)
  • 原文地址:https://www.cnblogs.com/2881064178dinfeng/p/6215516.html
Copyright © 2020-2023  润新知