Encapsulate common JS parameters for PHP calls: <? Php
//
//----------------------------------------------------------------------
// | JS javascript |
//----------------------------------------------------------------------
// | Copyright (c) 2001 NetFish Software |
// |
// | Author: whxbb (whxbb@21cn.com) |
//----------------------------------------------------------------------
//
// $ Id: js. class. php, v 0.1 2001/8/5 18:48:33 yf Exp $
//
// Prohibit direct access to this page
If (basename ($ HTTP_SERVER_VARS [PHP_SELF]) = "js. class. php "){
Header ("HTTP/1.0 404 Not Found ");
}
/**
* Purpose
* Some Common Javascript code is encapsulated for fast calling in PHP.
* @ Author: whxbb (whxbb@21cn.com)
* @ Version: 0.1
* @ Date: 2001/8/5
*/
Class JS
{
Function JS (){}
/**
* Return to the previous page
* @ Param $ the number of layers returned by step is 1 by default.
*/
Function Back ($ step =-1)
{
$ Msg = "history. go (". $ step .");";
JS: _ Write ($ msg );
JS: FreeResource ();
Exit;
}
/**
* The warning window is displayed.
* @ Param $ msg warning information
*/
Function Alert ($ msg)
{
$ Msg = "alert (" ". $ msg ."");";
JS: _ Write ($ msg );
}
/**
* Write js
* @ Param $ msg
*/
Function _ Write ($ msg)
{
Echo "<script language =" javascript "> ";
Echo $ msg;
Echo "</script> ";
}
/**
* Refresh the current page
*/
Function Reload ()
{
$ Msg = "location. reload ();";
JS: FreeResource ();
JS: _ Write ($ msg );
Exit;
}
/**
* Refresh the parent page
*/
Function ReloadOpener ()
{
$ Msg = "if (opener) opener. location. reload ();";
JS: _ Write ($ msg );
}
/**
* Jump to url
* @ Param $ url target page
*/
Function Goto ($ url)
{
$ Msg = "location. href = $ url ;";
JS: FreeResource ();
JS: _ Write ($ msg );
Exit;
}
/**
* Close the window
*/
Function Close ()
{
$ Msg = "window. close ()";
JS: FreeResource ();
JS: _ Write ($ msg );
Exit;
}
/**
* Submit a form
* @ Param $ frm form name
*/
Function Submit ($ frm)
{
$ Msg = $ frm. ". submit ();";
JS: _ Write ($ msg );
}
/**
* Close database connection
*/
Function FreeResource ()
{
// Database connection flag
Global $ conn;
If (is_resource ($ conn ))
@ Mysql_close ($ conn );
}
}
?>