最新制作完成的在线歌词搜索功效,利用ajax技巧,无刷新显示歌词,只需要输进你要查找的歌曲名或歌词。界面还不是很好看,完善中......
12378923<script language="javascript">24 var http_request = false;25 function send_request(url) {//初始化、指定处理函数、发送恳求的函数26 http_request = false;27 //开端初始化XMLHttpRequest对象28 if(window.XMLHttpRequest) { //Mozilla 浏览器29 http_request = new XMLHttpRequest();30 if (http_request.overrideMimeType) {//设置MiME种别31 http_request.overrideMimeType('text/xml');32 }33 }34 else if (window.ActiveXObject) { // IE浏览器35 try {36 http_request = new ActiveXObject("Msxml2.XMLHTTP");37 } catch (e) {38 try {39 http_request = new ActiveXObject("Microsoft.XMLHTTP");40 } catch (e) {}41 }42 }43 if (!http_request) { // 异常,创立对象实例失败44 window.alert("不能创立XMLHttpRequest对象实例.");45 return false;46 }47 http_request.onreadystatechange = processRequest;48 // 断定发送恳求的方法和URL以及是否同步履行下段代码49 http_request.open("GET", url, true);50 http_request.send(null);51 }52 // 处理返回信息的函数53 function processRequest() {54 if (http_request.readyState == 4) { // 判定对象状态55 if (http_request.status == 200) { // 信息已经成功返回,开端处理信息56 //alert(http_request.responseText);57 document.getElementById("result").innerHTML = http_request.responseText;58 } else { //页面不正常59 alert("您所恳求的页面有异常。");60 }61 }62 }63 function dosearch() {64 var f = document.form1;65 var geci = f.geci.value;66 if(geci=="") {67 window.alert("请输进你要查询的歌词");68 f.geci.focus();69 return false;70 }71 else {72 document.getElementById("result").innerHTML="正在查询,请稍候";73 send_request('http://www.efish.cn/getgeci.aspx?m=' escape(geci));74 }75 }76 function submitForm() { 77 if(window.event.keyCode==13) { 78 dosearch();79 } 80 } 81</script>82839192
请作者接洽本站,及时附注您的姓名。接洽邮箱:edu#chinaz.com(把#改为@)。