Use the underlying layer of Ajax to implement brushless search for lyrics

Source: Internet
Author: User
For example:

 

 

 

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> untitled document </title>
</Head>
 
<Body>
<Style type = "text/CSS">
<! --
Body {
Background-color: # ffffff;
Font-size: 85%;
Font-family: verdana;
Margin-top: 10px;
Margin-left: 10px;
}
A: link {color: #3737c8}
A: active {color: # f00 ;}
A: visited {color: #639 ;}
-->
</Style>

<Script language = "JavaScript">
VaR http_request = false;
Function send_request (URL) {// initialize, specify the processing function, and send the request Function
Http_request = false;
// Start initializing the XMLHTTPRequest object
If (window. XMLHttpRequest) {// Mozilla Browser
Http_request = new XMLHttpRequest ();
If (http_request.overridemimetype) {// sets the mime category
Http_request.overridemimetype ('text/xml ');
}
}
Else if (window. activexobject) {// IE browser
Try {
Http_request = new activexobject ("msxml2.xmlhttp ");
} Catch (e ){
Try {
Http_request = new activexobject ("Microsoft. XMLHTTP ");
} Catch (e ){}
}
}
If (! Http_request) {// exception. An error occurred while creating the object instance.
Window. Alert ("the XMLHTTPRequest object instance cannot be created .");
Return false;
}
Http_request.onreadystatechange = processrequest;
// Determine the request sending method and URL and whether to execute the following code synchronously
Http_request.open ("get", URL, true );
Http_request.send (null );
}
// Function for processing the returned information
Function processrequest (){
If (http_request.readystate = 4) {// judge the object status
If (http_request.status = 200) {// The information has been returned successfully. Start to process the information.
// Alert (http_request.responsetext );
Document. getelementbyid ("result"). innerhtml = http_request.responsetext;
} Else {// The page is abnormal.
Alert ("the page you requested has an exception. ");
}
}
}
Function dosearch (){
VaR F = Document. form1;
VaR geci = f. geci. value;
If (geci = ""){
Window. Alert ("Enter the lyrics you want to query ");
F. geci. Focus ();
Return false;
}
Else {
Document. getelementbyid ("result"). innerhtml = "querying... please wait ";
Send_request ('HTTP: // www.efish.cn/getgeci.aspx? M = '+ escape (geci ));
}
}
Function submitform (){
If (window. event. keycode = 13 ){
Dosearch ();
}
}
</SCRIPT>

<P> </P>
<Form ID = "form1" name = "form1" method = "Post" Action = "">
<Center> <span style = "font-size: 18px; color: # ff0000"> 100,000 online free query of lyrics </span> </center>
<P> </P>
Enter the song name:
<Input name = "geci" type = "text" id = "geci" value = "Dongfeng broken" size = "60" Height = "30" maxlength = "50" onkeydown =" submitform () "/>
<Input type = "button" name = "Search" value = "query lyrics" onclick = "dosearch ()"> <br/>
<Span id = "result"> </span>
</Form>
</Body>
</Html>

Related Article

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.