我想做一個類似QQ空間評論的功能
不知大家發現了沒有 QQ空間只有點擊了那個文字框後編輯器才會載入出來
並不是那種先隱藏 通過單擊後才顯示的
<!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>無標題文檔</title> <script type="text/javascript"> //the function can get the content of right page when user click the link in the left side var xmlHttp; var searching=false; var myDivName=""; function getXMLHTTP(){ A = new ActiveXObject("microsoft.xmlhttp"); return A; } function executeQuery(divName,url) { searching = true; myDivName = divName; if(xmlHttp && xmlHttp.readystate != 0) { xmlHttp.abort(); } xmlHttp=getXMLHTTP(); var tempurl=""; if(xmlHttp && myDivName!=""){ tempurl += url + ".htm" + "?";//載入文擋類型 tempurl += "&" + new Date().getTime(); xmlHttp.open("Get", tempurl , true); xmlHttp.onreadystatechange = getReturnHtml; xmlHttp.send(null); }else{ searching = false; myDivName = ""; window.alert('系統太忙,請稍後再試!'); return false; } } function getReturnHtml(){ if(xmlHttp.readyState==1) { document.getElementById(myDivName).innerHTML =""; } else if(xmlHttp.readystate == 4 && xmlHttp.responsetext && searching) { //alert (myDivName); document.getElementById(myDivName).innerHTML = xmlHttp.responsetext; //alert(xmlHttp.responseText); searching = false; } else{ document.getElementById(myDivName).innerHTML ="拒絕訪問"; } } </script> <style type="text/css"> <!-- #Layer1 { position:absolute; left:8px; top:53px; width:675px; height:auto; z-index:1; border:1px solid #000; overflow:auto; } --> </style> </head> <body> <div id="Layer1"></div> <label> <input type="button" name="Submit" value="在下面載入新聞" onclick="executeQuery('Layer1','http://www.jb51.net')" /> </label> </body> </html>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]