Php encapsulates some common JS operations. In web programming, you should often use some common js operations, such as alert (), which are often inspired by the company when writing again, I have simply written a class to automatically generate these classes. in web programming, you should often use some common js operations, such as alert (), which is usually re-written, inspired by the company, I simply wrote a class to automatically generate these js files. The purpose is to make it easy. new users may like javas_^.
[Php]
/*
* Page: makeJs. class. php
* Function: encapsulate common JS code and call it directly to facilitate operations
* Author: Boss Hui
* Creation time:
*/
Class makeJs
{
Private $ jsStartChar =' '; // Defines the js start mark
Private $ jsEndChar =' '; // Defines the js end mark
/*
* Function name: jsAlert
* Function: a JS prompt box is displayed.
* Parameter: $ message indicates the text to be displayed in the pop-up box. $ url indicates the jump path after the url is clicked. if it is null, no jump is made.
* Usage:
* $ Js = new makeJs (); // The following describes how to omit this sentence
* $ Js-> jsAlert (displayed text, 'Jump to page URL'); // in the displayed dialog box, click OK to go to the php. php page.
* $ Js-> jsAlert (displayed text, ''); // The pop-up dialog box is displayed. if you click OK, no jump is displayed.
*/
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: a JS prompt box is displayed, with confirmation or cancellation.
* Parameter: $ message indicates the text to be displayed in the pop-up prompt box.
* Usage: $ js-> jsConfirm ('displayed text ');
*/
Public function jsConfirm ($ message ){
Echo $ this-> jsStartChar;
If ($ url = ''){
Echo 'confirm'. '("'. $ message .'");';
Echo $ this-> jsEndChar;
}
}
/*
* Function name: jsOpenWin
* Function: a new window is displayed.
* Parameter: $ url path $ name window name $ height window height $ width window width
* Usage:
* $ Url = 'Page url ';
* $ 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 extends pt
* Function: Custom JS
* Parameter: $ scr platinum pt
* Usage:
* $ Scr define pt = 'JS statement ';
* Example: $ scr using pt = 'window. location = (\ 'php. php \')';
* $ Js-> jsAddscr merge pt ($ scr merge pt );
*/
Public function jsAddscr extends pt ($ scr extends pt ){
Echo $ this-> jsStartChar;
Echo $ scr platinum pt;
Echo $ this-> jsEndChar;
}
}
?>
[/Php]
Margin (), which is often encountered again. inspired by the company, I simply wrote a class to automatically generate these...