Php encapsulates some common JS operations.

Source: Internet
Author: User
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...

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.