In the Web programming people should often use some common JS operations, such as alert (), usually encountered a re-write, inspired by the company, I wrote a simple class to automatically generate these JS, the purpose is to facilitate, a gadget, novices may like ^_^
[PHP]
/*
* Page: makeJs.class.php
* Function: Packaging common JS code, direct call, easy to operate
* Author: Hui boss
* Date Created: 2007-01-27
*/
Class Makejs
{
Private $jsStartChar = ' ';//define JS start tag
Private $jsEndChar = ' ';//define JS end tag
/*
* Function Name: Jsalert
* Function function: Popup JS prompt box
* Parameters: $message The text to be displayed in the pop-up prompt $url the path to jump after the click, the blank does not jump
* How to use:
* $js = new Makejs ();//The following describes how to omit this sentence
* $js->jsalert (display text, ' jump page URL '),//Popup dialog, click OK to jump to php.php page
* $js->jsalert (displayed text, ');//Popup dialog box, click OK and no jump
*/
Public Function Jsalert ($message, $url) {
Echo $this->jsstartchar;
if ($url = = ") {
echo ' alert '. '("' . $message. '");';
Echo $this->jsendchar;
}
else{
echo ' alert '. '("' . $message. '");';
Echo $this->jsendchar;
Echo ' ';
}
}
/*
* Function Name: jsconfirm
* Function function: Popup js prompt box with OK/Cancel
* Parameters: $message The text to display in the popup prompt box
* How to use: $js->jsconfirm (' displayed text ');
*/
Public Function jsconfirm ($message) {
Echo $this->jsstartchar;
if ($url = = ") {
echo ' Confirm '. '("' . $message. '");';
Echo $this->jsendchar;
}
}
/*
* Function Name: Jsopenwin
* Function function: Popup new Window
* Parameters: $url path $name window name $height window height $width window width
* How to use:
* $url = ' URL of the page ';
* $js->jsopenwin ($url, window name, window height, window width);
*/
Public Function Jsopenwin ($url, $name, $height, $width) {
Echo $this->jsstartchar;
Echo ' window.open '. ' ("'. $url. '", "'. $name. '", "'. $height. '", "'. $width. '");
Echo $this->jsendchar;
}
/*
* Function Name: jsaddscrīpt
* Function function: Custom JS
* Parameters: $scr īpt
* How to use:
* $SCR īpt = ' defined JS statement ';
* For example: $scr īpt = ' window.location= (\ ' php.php\ ') ';
* $js->jsaddscrīpt ($scr īpt);
*/
Public Function jsaddscrīpt ($scr īpt) {
Echo $this->jsstartchar;
echo $SCR īpt;
Echo $this->jsendchar;
}
}
?>
[/php]
http://www.bkjia.com/PHPjc/317879.html www.bkjia.com true http://www.bkjia.com/PHPjc/317879.html techarticle in the Web programming people should often use some common JS operations, such as alert (), usually encountered a re-write, inspired by the company, I wrote a simple class to automatically generate these ...