详情介绍
首先创建一个PHP文件,并打开编辑;
然后在PHP代码中用函数“echo()”输出JS代码;
接着在JS代码中使用函数“alert()”提示消息;
最后将JS中“location.href”指向跳转链接即可。
代码示例:
function show_msg($msg, $url) { echo "<script>alert('{$msg}');window.location.href='{$url}';</script>"; exit(); } show_msg('this is Message!', '/user/show');
进阶版
function message($msgTitle,$message,$jumpUrl){ $str = '<!DOCTYPE HTML>'; $str .= '<html>'; $str .= '<head>'; $str .= '<meta charset="utf-8">'; $str .= '<title>页面提示</title>'; $str .= '<style type="text/css">'; $str .= '*{margin:0; padding:0}a{color:#369; text-decoration:none;}a:hover{text-decoration:underline}body{height:100%; font:12px/18px Tahoma, Arial, sans-serif; color:#424242; background:#fff}.message{width:450px; height:120px; margin:16% auto; border:1px solid #99b1c4; background:#ecf7fb}.message h3{height:28px; line-height:28px; background:#2c91c6; text-align:center; color:#fff; font-size:14px}.msg_txt{padding:10px; margin-top:8px}.msg_txt h4{line-height:26px; font-size:14px}.msg_txt h4.red{color:#f30}.msg_txt p{line-height:22px}'; $str .= '</style>'; $str .= '</head>'; $str .= '<body>'; $str .= '<div class="message">'; $str .= '<h3>'.$msgTitle.'</h3>'; $str .= '<div class="msg_txt">'; $str .= '<h4 class="red">'.$message.'</h4>'; $str .= '<p>系统将在 <span style="color:blue;font-weight:bold">3</span> 秒后自动跳转,如果不想等待,直接点击 <a href="{$jumpUrl}">这里</a> 跳转</p>'; $str .= "<script>setTimeout('location.replace('".$jumpUrl."')',2000)</script>"; $str .= '</div>'; $str .= '</div>'; $str .= '</body>'; $str .= '</html>'; echo $str; }
1、升级本站永久VIP,仅需【49】元即可升级 ! ! ! (升级后永久享受整站资源全部免费下载)
2、站内资源均可通过签到等任务进行免费兑换。
3、站内资源均来源于网络公开发表文件或网友投稿发布,如侵犯您的权益,请联系管理员处理。
4、本站所分享的源码、模板、软件工具等其他资源,都不包含技术服务,请大家谅解!
5、所有资源均收集于互联网仅供学习、参考和研究,请理解这个概念,所以不能保证每个细节都符合你的需求,也可能存在未知的BUG与瑕疵,因本站资源均为可复制品,所以不支持任何理由的退款兑现(特殊情况可退积分),请熟知后再支付下载!
评论(0)条