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'
    );
    }

  • 相关阅读:
    ES6新特性
    浏览器兼容问题
    跨域
    箭头函数与普通函数的区别
    单页面应用
    vue试题
    Git 常用命令
    【分享代码】一个笨办法获取容器的剩余内存
    【笔记】thanos receiver的router模式
    【分享】让prometheus支持PUSH模式,可以使用remote write协议推送数据
  • 原文地址:https://www.cnblogs.com/2881064178dinfeng/p/6215516.html
Copyright © 2011-2022 走看看