声明下:此教程来自TP官网,如果需要看原文,请点击一下链接   http://www.thinkphp.cn/code/3437.html

先给大家看下效果:

直接撸代码:

第一步:为了增加对移动设备的支持,在common.php加入以下函数:

function isMobile()
{
if (isset ($_SERVER['HTTP_X_WAP_PROFILE']))
{
return true;
}
if (isset ($_SERVER['HTTP_VIA']))
{
return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
}
if (isset ($_SERVER['HTTP_USER_AGENT']))
{
$clientkeywords = array ('nokia',
'sony',
'ericsson',
'mot',
'samsung',
'htc',
'sgh',
'lg',
'sharp',
'sie-',
'philips',
'panasonic',
'alcatel',
'lenovo',
'iphone',
'ipod',
'blackberry',
'meizu',
'android',
'netfront',
'symbian',
'ucweb',
'windowsce',
'palm',
'operamini',
'operamobi',
'openwave',
'nexusone',
'cldc',
'midp',
'wap',
'mobile'
);
if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT'])))
{
return true;
}
}
if (isset ($_SERVER['HTTP_ACCEPT']))
{
if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html'))))
{
return true;
}
}
return false;
}

第2步:替换模板

这个文件里面的代码全部删除,加入以下代码:

{__NOLAYOUT__}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>跳转提示</title>
<?php if(isMobile()==true){?>
<style type="text/css">
body, h1, h2, p,dl,dd,dt{margin: ;padding: ;font: 15px/1.5 微软雅黑,tahoma,arial;}
body{background:#efefef;}
h1, h2, h3, h4, h5, h6 {font-size: %;cursor:default;}
ul, ol {list-style: none outside none;}
a {text-decoration: none;color:#447BC4}
a:hover {text-decoration: underline;}
.ip-attack{width:%; margin:200px auto ;}
.ip-attack dl{ background:#fff; padding:30px; border-radius:10px;border: 1px solid #CDCDCD;-webkit-box-shadow: 8px #CDCDCD;-moz-box-shadow: 8px #cdcdcd;box-shadow: 8px #CDCDCD;}
.ip-attack dt{text-align:center;}
.ip-attack dd{font-size:16px; color:#; text-align:center;}
.tips{text-align:center; font-size:14px; line-height:50px; color:#;}
</style>
<?php }else{ ?>
<style type="text/css">
body, h1, h2, p,dl,dd,dt{margin: ;padding: ;font: 15px/1.5 微软雅黑,tahoma,arial;}
body{background:#efefef;}
h1, h2, h3, h4, h5, h6 {font-size: %;cursor:default;}
ul, ol {list-style: none outside none;}
a {text-decoration: none;color:#447BC4}
a:hover {text-decoration: underline;}
.ip-attack{width:600px; margin:200px auto ;}
.ip-attack dl{ background:#fff; padding:30px; border-radius:10px;border: 1px solid #CDCDCD;-webkit-box-shadow: 8px #CDCDCD;-moz-box-shadow: 8px #cdcdcd;box-shadow: 8px #CDCDCD;}
.ip-attack dt{text-align:center;}
.ip-attack dd{font-size:16px; color:#; text-align:center;}
.tips{text-align:center; font-size:14px; line-height:50px; color:#;}
</style>
<?php }?> </head>
<body>
<div class="ip-attack"><dl>
<?php switch ($code) {?>
<?php case :?>
<dt style="color: green"><?php echo(strip_tags($msg));?></dt>
<?php break;?>
<?php case :?>
<dt style="color: red"><?php echo(strip_tags($msg));?></dt>
<?php break;?>
<?php } ?>
<br>
<dt>
页面自动 <a id="href" href="<?php echo($url);?>">跳转</a> 等待时间: <b id="wait"><?php echo($wait);?></b>
</dt></dl>
</div>
<script type="text/javascript">
(function(){
var wait = document.getElementById('wait'),
href = document.getElementById('href').href;
var interval = setInterval(function(){
var time = --wait.innerHTML;
if(time <= ) {
location.href = href;
clearInterval(interval);
};
}, );
})();
</script>
</body>
</html>

搞定!!!

thinkphp5最美跳转页面的更多相关文章

  1. JS定时刷新页面及跳转页面

    JS定时刷新页面及跳转页面 Javascript 返回上一页1. Javascript 返回上一页 history.go(-1), 返回两个页面: history.go(-2); 2. history ...

  2. Webform Session、Cookies传值,跳转页面方式

    Session:每个独立的浏览器都会创建一个独立的Session,不是一台电脑一个Session 存放位置:服务器上 作用:只要里面有内容,那么这个网站中所有的C#端都能访问到这个变量 优点:安全,速 ...

  3. 跳转页面,传递参数——android

    android 跳转页面并传递对象(实体类)——项目中是集港收货类 网上资料:两种传递方法Serializable,parcelable 优劣比较:Serializable数据更持久化,网络传输或数据 ...

  4. Response.Redirect 无法跳转页面

    错误现象:Response.Redirect(Server.MapPath("BackIndex.aspx")); 打断点测试执行了这一句,Server.MapPath(" ...

  5. xamarin.ios 跳转页面

    一:用Segue跳转页面 按住Ctrl连线,选择show,后台覆写 ShouldPerformSegue方法,返回True跳转,False取消跳转.   二:通过代码跳转至StoryBoard页面 U ...

  6. 常用的js跳转页面方法实现汇总

    1.window.location.href方式 <script language="javascript" type="text/javascript" ...

  7. JavaScript学习笔记-简单的倒计时跳转页面

    <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...

  8. iOS极光推送 点击推送消息跳转页面

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launc ...

  9. 使用Android点击按钮跳转页面

    1.首先新建一个Android工程,命名为MyApp(名字可以自己随意起); 2.以原有的MainActivity.java文件为登录界面,然后在src文件中的包上面右击选择New目录下的Other中 ...

随机推荐

  1. Nginx+tomcat+redis集群共享session实现负载均衡

    1.nginx是一款轻量级兼备高性能的Http和反向代理服务器.所谓反向代理就是指用户发起访问请求,由代理服务器接受,然后将请求转发给正式服务器,并且将正式服务器处理完的数据返回给客户单,此时代理服务 ...

  2. perf原理再看

    vim ./arch/x86/kernel/hw_breakpoint.c perf如何控制采样的频率 perf采样不同的事件,得到的不是一样 cycles: 向PMU中增加不同的函数,增加不同 使用 ...

  3. [C/C++] “箭头(->)”和“点号(.)”的区别

    转自:http://blog.csdn.net/gyymen/article/details/4962873 首先介绍一下C++中的结构.对于一个结构: struct MyStruct { int m ...

  4. [洛谷P1231] 教辅的组成

    题目大意:有n1本书,n2本练习册和n3个答案,然后又一些条件,说明某本答案可能和某本书对应,某本练习册可能和某本书对应,求最多有多少本完整的书(有书,练习册,答案) 题解:网络流,对应就连边,然后考 ...

  5. BZOJ2115 [Wc2011] Xor 【线性基】

    2115: [Wc2011] Xor Time Limit: 10 Sec  Memory Limit: 259 MB Submit: 3915  Solved: 1633 [Submit][Stat ...

  6. BZOJ2120 数颜色 【带修改莫队】

    2120: 数颜色 Time Limit: 6 Sec  Memory Limit: 259 MB Submit: 6579  Solved: 2625 [Submit][Status][Discus ...

  7. 【BZOJ 2241 打地鼠】

    Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 1430  Solved: 908[Submit][Status][Discuss] Descripti ...

  8. BZOJ 题解continue

    1041 圆上的整点 暴力枚举 会超时 这道题很像之前一次noip模拟题(当时的我还太水了(虽然现在也很水)) x2+y2=R2 考虑变型 x2=(R+y)(R-y) int d=gcd(R,y) i ...

  9. 洛谷P1339 热浪

    P1339 热浪 529通过 1.3K提交 题目提供者yeszy 标签图论福建省历届夏令营 难度普及+/提高 提交该题 讨论 题解 记录 最新讨论 求助...为什么是未知错误… 求修正,貌似死循环 第 ...

  10. codeforces 1015A

    A. Points in Segments time limit per test 1 second memory limit per test 256 megabytes input standar ...