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'
);
}
ThinkPHP跳转与重定向的区别在哪里的更多相关文章
- ThinkPHP跳转与重定向的区别
跳转: 浏览器认为: 当前URL请求成功, 重新请求新的URL. 浏览器会 记录当前的URL 和 新的URL 在请求历史记录中. 回退, 是可以回退到, 当前的URL上的. (无论 success, ...
- thinkphp 跳转和重定向
页面跳转 在应用开发中,经常会遇到一些带有提示信息的跳转页面,例如操作成功或者操作错误页面,并且自动跳转到另外一个目标页面.系统的\Think\Controller类内置了两个跳转方法success和 ...
- php中的页面跳转和重定向
php中的页面跳转和重定向 ThinkPHP中跳转和重定向的区别 跳转: 浏览器认为: 当前URL请求成功, 重新请求新的URL. 浏览器会 记录当前的URL 和 新的URL 在请求历史记录中. 回退 ...
- Servlet中转发和重定向的区别
Servlet中页面的跳转有两种方式:转发和重定向. 1.转发和重定向的区别 ①转发是服务器行为,重定向是客户端行为. ②转发是浏览器发生了一次请求,重定向至少是两次请求. ③转发地址栏中的url不会 ...
- servlet之转发与重定向的区别
转发(服务器端跳转): 一次请求 <jsp:forward> request.getRequestDispatcher("new.jsp").forward(requ ...
- Servlet-转发和重定向的区别
实际发生位置不同,地址栏不同 转发是发生在服务器上的 转发是由服务器进行跳转的,细心的朋友会发现,在转发的时候,浏览器的地址栏是没有发生变化的,在我访问Servlet111的时候,即使跳转到了Serv ...
- JSP转发和重定向的区别
重定向: response.sendRedirect("地址"); a. 页面地址显示最终页面 b. 不可向后传递参数 c. 跳到外 ...
- jsp内置对象 转发与重定向的区别
jsp 内置对象 转发与重定向的比较 重定向和转发有一个重要的不同:当使用转发时,JSP容器将使用一个内部的方法来调用目标页面,新的页面继续处理同一个请求,而浏览器将不会知道这个过程. 与之相反,重 ...
- thinkphp 跳转外网代码(php通用)
thinkphp 提供了一个重定向但是在跳转外部网站的时候就会比较麻烦 下面一种方法还不错, < ?php //重定向浏览器 header("Location: http://www. ...
随机推荐
- yaffs2物理存储
了解一个文件系统,除了了解运行机制(RAM结构)外,还需了解文件系统怎样物理存储的.RAM数据结构是为文件系统更好运行,而物理存储是文件系统载体.文件系统出问题后,最终要从物理存储寻找数据.参考&qu ...
- WPF程序只运行一个实例
1.WPF程序在 启动窗口的构造函数执行InitializeComponent之前判断是否已经存在实例 不涉及服务器情况,可直接进行判断(不在mainwindow的构造函数中判断) // public ...
- [GeoServer]重拾GeoServer之安装篇
GeoServer的项目是一个完整的Java(J2EE)系统,现实了OpenGIS联盟的网络功能服务器规范和网络覆盖服务器规范,并且集成了Web地图服务器. 在大三的时候WebGIS课程中老师讲解过一 ...
- 使用pgbench测试PostgreSQL
pgbench –help 初始化选项: -i 调用初始化模式 -F NUM 填充因子 -s NUM 规模因子(与产生数据量大小有关) Benchmarking选项: -c ...
- 树形DP(Rebuilding Roads poj1947)
题意:给出一颗树,求要形成一颗元素个数是p的子树,最少要去掉多少边 #include"stdio.h" #include"string.h" #include& ...
- [原创]java WEB学习笔记73:Struts2 学习之路-- strut2中防止表单重复提交
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- 常见http代码错误原因及处理
常见的HTTP错误可以分为以下四大类.每一大类又细分为很多类小错误.当您打不开网站或者打开网站报错时首先检查您输入的网站是否有误,检查网络是否有问题或者虚拟主机的DNS是否可以解析.确定没有问题时再看 ...
- Mysql索引介绍及常见索引(主键索引、唯一索引、普通索引、全文索引、组合索引)的区别
Mysql索引概念:说说Mysql索引,看到一个很少比如:索引就好比一本书的目录,它会让你更快的找到内容,显然目录(索引)并不是越多越好,假如这本书1000页,有500也是目录,它当然效率低,目录是要 ...
- 比较二个文件的最后修改时间FileListener
import java.io.File; import java.text.SimpleDateFormat; import java.util.Timer; import java.util.Tim ...
- java经典小算法
package com.shb.java; public class Demo4 { /**时间有限 先不写文字了 自己随便敲的 * @param args * @author shaobn */ p ...