PHP 实现类似js中alert() 提示框_php实例

WBOY
Release: 2016-06-07 17:13:47
Original
858 people have browsed it

主要应用于添加判断提示,跳转,返回,刷新。

复制代码 代码如下:

/**
 * JS提示跳转
 * @param  $tip  弹窗口提示信息(为空没有提示)
 * @param  $type 设置类型 close = 关闭 ,back=返回 ,refresh=提示重载,jump提示并跳转url
 * @param  $url  跳转url
 */
function alert($tip = "", $type = "", $url = "") {
    $js = "<script>";<br /> if ($tip)<br /> $js .= "alert('" . $tip . "');";<br /> switch ($type) {<br /> case "close" : //关闭页面<br /> $js .= "window.close();";<br /> break;<br /> case "back" : //返回<br /> $js .= "history.back(-1);";<br /> break;<br /> case "refresh" : //刷新<br /> $js .= "parent.location.reload();";<br /> break;<br /> case "top" : //框架退出<br /> if ($url)<br /> $js .= "top.location.href='" . $url . "';";<br /> break;<br /> case "jump" : //跳转<br /> if ($url)<br /> $js .= "window.location.href='" . $url . "';";<br /> break;<br /> default :<br /> break;<br /> }<br /> $js .= "</script>";
    echo $js;
    if ($type) {
        exit();
    }
}

以上所述就是本文的全部内容了,希望对大家学习php能有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!