Encapsulate commonly used JS parameters to facilitate PHP calls: <?php
//
// +----------------------------------------------------------------------+
// | JS JavaScript Class |
// +----------------------------------------------------------------------+
// | 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
* Encapsulates some of the most commonly used JavaScript code for quick calls in PHP
* @author: WHXBB (whxbb@21cn.com)
* @version: 0.1
* @date: 2001/8/5
*/
Class JS
{
function JS () {}
/**
* Go back to the previous page
* @param $step The number of layers returned defaults to 1
*/
function back ($step =-1)
{
$msg = "History.go (". $step. ");";
Js::_write ($msg);
Js::freeresource ();
Exit
}
/**
* Pop-up Warning window
* @param $msg warning message
*/
function Alert ($msg)
{
$msg = "alert (\". $msg. " \");";
Js::_write ($msg);
}
/**
* Write JS
* @param $msg
*/
function _write ($msg)
{
echo "<script language=\" javascript\ ">\n";
Echo $msg;
echo "\n</script>";
}
/**
* Refresh Current Page
*/
function Reload ()
{
$msg = "location.reload ();";
Js::freeresource ();
Js::_write ($msg);
Exit
}
/**
* Refresh Popup 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
}
/**
* Submitting Form
* @param $frm Table Single-name
*/
function Submit ($FRM)
{
$msg = $frm. ". Submit (); ";
Js::_write ($msg);
}
/**
* Close Database connection
*/
function FreeResource ()
{
Database connection Flags
Global $conn;
if (Is_resource ($conn))
@mysql_close ($conn);
}
}
?>