這個問題是今天在外出門得到的@@..感覺近這幾天學了不少東西,也試了不少東西,真的很開心..多謝朋友和我這呆心聊程式..
其實這部份在外出前的一刻就已經想好像這樣寫,不過由於準備出門,所以回來後立即將記憶中的片段整理了一下就寫了以下的代碼
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| <script language="javascript" type="text/javascript"> function makeRequest(url,funcname,httptype,senddata) { var chgfunc; http_request=false; if(!httptype) { httptype='GET'; } if(window.XMLHttpRequest) { http_request=new XMLHttpRequest(); if(http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); } } else if(window.ActiveXObject) { try { http_request=new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) { try { http_request=new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) { } } } if(!http_request) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; } chgfunc='http_request.onreadystatechange = '+funcname; eval(chgfunc); http_request.open(httptype,url,true); http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); http_request.send(senddata); }
function ajaxGet(url,funcname,httptype,senddata) { if(''==httptype) { httptype=null; } if(''==senddata) { senddata=null; } alert('1'); makeRequest(url,funcname,httptype,senddata); } function popHome() { if(http_request.readyState == 4) { if(http_request.status == 200) { var allData = http_request.responseText; var homeWin = window.open("","homeWin"); homeWin.document.open(); homeWin.document.write(allData); homeWin.document.close(); } else{ alert('Show Reply Data Error!'); } } } </script> <a href="#home" onclick="ajaxGet('home.html','popHome')">個人資料</a>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| <!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=UTF-8"> <title> new document </title> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="-1" /> <meta http-equiv="Cache-Control" content="no-cache" /> <link rel="stylesheet" type="text/css" media="screen" href="" /> <script src="" language="javascript" type="text/javascript"></script> </head> <body> <div id="top">This Is A Test Page</div> <hr size="0" /> <ul> <li>Test 1</li> <li>Test 2</li> </ul> </body> </html>
|