<%@pagecontentType="text/html; charset=UTF-8"%> <%@pagelanguage="java"%> <!DOCTYPEhtml PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-type"content="text/html; charset=utf-8"> <title>动态加载的FAQ</title>
<scriptsrc="getServerRenspose.js"type="text/javascript"></script> <scripttype="text/javascript"> var r="read_faq.jsp"; var f="faqDetail"; function clickLoad1(){ loadFAQ(1,"read_faq.jsp","faqDetail"); } function clickLoad2(){ loadFAQ(2,"read_faq.jsp","faqDetail"); } function clickLoad3(){ loadFAQ(3,"read_faq.jsp","faqDetail"); } </script>
var xmlHttp; var currFaqId; var divID; //Create XMLHttpRequest Object function createXmlHttp(){ //window.XMLHttpRequest isExist? if(window.XMLHttpRequest){ xmlHttp =new XMLHttpRequest();//Browsers:FireFox、Opera
}else{ xmlHttp =newActiveXObject("Microsoft.XMLHTTP");//Browser:IE } } //getFAQ_Informations function loadFAQ(faqId,topage,div){ currFaqId = faqId;//remember Currently FAQ_ID divID=div; var currFaqDetail = getFaqDetailDiv(faqId);//get Currently List if(currFaqDetail.style.display=="none"){ currFaqDetail.style.display="block";//Div State is Block //FAQ isExist?;if null ,get Information from Server if(currFaqDetail.innerHTML==""){ createXmlHttp();//Create XmlHttpRequest Object xmlHttp.onreadystatechange= loadFAQCallback; xmlHttp.open("GET",topage+"?faqId="+ faqId,true); xmlHttp.send(null); } }else{ currFaqDetail.style.display="none";//div state is none } } //get FAQ Information function loadFAQCallback(){ if(xmlHttp.readyState== 4){ getFaqDetailDiv(currFaqId).innerHTML= xmlHttp.responseText;//FAQ into Div } } //get div function getFaqDetailDiv(faqId){ returndocument.getElementById(divID + faqId); }