JS usage summary _ ax

Source: Internet
Author: User
I. Use Re
// Made by ax
Function Ax ()
{
VaR Zhz = " Safdasjlk; DFL " ;
// Declare Regular Expression
VaR Re =   New Regexp ( " ^ [\ W] + \ [\ W-/.: ~] + ;? $ | ^ ([\ W] + \ [\ W-/.: ~] +;) + [\ W] + \ [\ W-/.: ~] + ;?) $ " );

// Use Re
If (Re. Test (zhz ))
{
Alert ("Matched!");
}
Else
{
Alert ("It's not matched ~!");
}
}


Ii. Press ENTER event to implement the button click Function
Function Enterevent_ax ()
{
If (Event. keycode =   13 )
{
//This statement can be left empty, but sometimes the cliclk event may not be triggered.
Document. All (btnfind). Focus ();
Document. All (btnfind). Click ();
}
}

III. How to call JS functions (The onclick of a button is an exception and can only be added in the background)
...... if you are free tomorrow, write ~
① write at the front end: call four methods at the same time form id =" form1 " runat =" server " onload =" ax0 (); ax1 (); ax2 (); ax3 () " >

② Write in the background: call four methods at the same timeThis. Txtsearchcomputer. Attributes. Add ("Onkeydown","Controlenterevent (); ax0 (); ax1 (); ax2 ()");

Iv. How to call the script file: add
./Indicates the root path ../indicates that the upper-level directory of the page Directory is the current path if it is not written.

< Script Language = "JavaScript" Type = "Text/JavaScript" SRC = "./Ax. js" > </ Script >
< Link Href = "../Ax.css" REL = "Stylesheet" Type = "Text/CSS"   />

V. Two Methods for forcible PostBack (and acquisition of event sources)


// Trigger an event when you click the check box
Function Forcepostback ()
{
VaR O = Window. event. srcelement;
If (O. tagname =   " Input "   && O. Type =   " Checkbox " )
{
_ Dopostback ("","");
}  
}

// Method 2
Function Forcepostback ()
{
Document. Forms [0]. Submit ();
}

VI. use the script to control the control style document. getelementbyid ( " AAA " ). classname = " ax " ;

Another background implementationTextbox1.attributes. Add ("Class","Css_ax");
Textbox1.cssclass= "Css_ax";

VII. Determine whether a string is in another string If ( " Axzhz " . Indexof ( " Zhz " ) >- 1 )
{
Alert ("'Zhz 'has exist in 'axzhz'");
}

Viii. The variable contains the script tag. /**/ /// <Summary>
///Volume of changes with lower-level labels
/// </Summary>
Private   Void Ax_outputjsvariable ()
{
// <! -- // --> It is the key for scripts in ax to not report errors.
// \ R \ n is the line feed in the script, and it is also related. (do not believe it)
Response. Write ( " <Script language = 'javascript '> <! -- \ R \ n " );
Response. Write ( " VaR AX = 'alert (\ 'made by axzhz \')'; " );
Response. Write ( " Alert (ax ); " );
Response. Write ( " \ R \ N // --> </SCRIPT> " );
}

IX. type conversion
Force:
Boolean (value) ---- ""/0/null --- false
Number (value)
String (value)
Convert to string:
Tostring ()
Convert to a number:
Parseint (value)

X. open a new window (more suitable for the export function)Window. Open ("Axzhz. aspx","Ax");


Blog garden → axe to help Shao Zhu

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.