zoukankan      html  css  js  c++  java
  • 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'
    );
    }

  • 相关阅读:
    numpy中linspace用法 (等差数列创建函数)
    Ubuntu环境下 matplotlib 图例中文乱码
    转载: 广义逆矩阵
    matplotlib.pyplot中add_subplot方法参数111的含义
    转载:(论文) 二次指数平滑法中确定初始值的简便方法
    图像处理之 opencv 学习---opencv 中的常用算法
    图像处理之 opencv 学习---矩阵的操作
    编译异常之static和extern---more than one storage class specified
    格式转换至yuv422转 yuv420
    阶段3 3.SpringMVC·_02.参数绑定及自定义类型转换_6 自定义类型转换器代码编写
  • 原文地址:https://www.cnblogs.com/2881064178dinfeng/p/6215516.html
Copyright © 2011-2022 走看看