Two JS classes encapsulate common JavaScript so that PHP can quickly call

Source: Internet
Author: User
js| Package <?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);
}
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.