最近使用ThinkSNS发现用$this->success(‘mes‘,‘url‘);无法实现跳转,想来它也是用TP框架搭起来的,这让我很是郁闷。然后就查找源文件看了一下,
<script> /** * 全局变量 */ var SITE_URL = ‘<php> echo SITE_URL;</php>‘; var UPLOAD_URL= ‘<php> echo UPLOAD_URL;</php>‘; var THEME_URL = ‘__THEME__‘; var APPNAME = ‘<php> echo APP_NAME;</php>‘; var MID = ‘<php> echo $mid;</php>‘; var UID = ‘<php> echo $uid;</php>‘; var initNums = ‘<php> echo $initNums;</php>‘; var SYS_VERSION = ‘<php> echo $site["sys_version"];</php>‘ // Js语言变量 var LANG = new Array(); function Jump(){ window.location.href = ‘{$jumpUrl}‘; } document.onload = setTimeout("Jump()" , {$waitSecond}* 1000); </script>
原来它对TP的success进行了简单修改,
window.location.href = ‘{$jumpUrl}‘;
也就是说当你提示完信息之后,要想跳转到指定页面 必须这样干:
$this->assign(‘jumpUrl‘, U(‘url‘,array(‘post_id‘=>$res))); $this->success(‘发布成功‘);
然后你还可以规定跳转的时间:
document.onload = setTimeout("Jump()" , {$waitSecond}* 1000);
同样也是用assign();
好了,就这样吧!!小知识,大用处!
原文地址:http://lisuoit.blog.51cto.com/9803786/1672845