<?php
/**
 * 文件: alert.class.php
 * 功能: 对客户端window封装,使用php控制客户端行为
 * @author xiaog
 */
class clientWindow {
    private
        static $SCRIPT = "<script type=text/javascript>%s</script>";

 

    /**
     * 客户端转向
     */
    public static function redirect($url){
        printf(self::$SCRIPT, "location.href=\"".self::fixMsg($url)."\"");
    }

    /**
     * 向客户端发送弹出信息
     */
    public static function alert($msg) {
        printf(self::$SCRIPT, "alert(\"".self::fixMsg($msg)."\");");
    }

    /**
     * 向客户端发送弹出信息并结束页面执行
     */
    public static function alertAndExit($msg) {
        clientWindow::alert($msg);
        exit;
    }

    private static function fixMsg($msg){
        return str_replace("\"", '\"', $msg);
    }
}

相关文章:

  • 2022-12-23
  • 2021-06-20
  • 2021-09-26
  • 2021-11-09
  • 2021-11-14
  • 2021-07-24
  • 2021-06-30
猜你喜欢
  • 2022-12-23
  • 2021-11-07
  • 2021-06-22
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案