var xmlHttp; function createXHR(){ if (window.XMLHttpRequest) { //IE7、Mozilla、Safari、Firefox... xmlHttp = new XMLHttpRequest(); if(xmlHttp.overrideMimeType){ xmlHttp.overrideMimeType('text/xml'); } }else if (window.ActiveXObject) {//IE6 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } if (!xmlHttp) { alert('您使用的瀏覽器不支援 XMLHTTP 物件'); return false; } } /* function readRequest(par_str,sdid,evalstr){ createXHR(); eval_str = evalstr; sd_id = sdid; var url='index.php?_Page=ajax&timeStamp='+new Date().getTime(); xmlHttp.open('POST',url,true);//POST or GET xmlHttp.onreadystatechange=callback; xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); //for POST xmlHttp.send(par_str); } */ function callback(){ if (xmlHttp.readyState==4){ xml=xmlHttp.responseXML; if(xml.childNodes.length == 0 ){ //for ie7 或不能正常解析PHP產生的XML,改抓text在轉xml xml=xmlHttp.responseText; var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.loadXML(xml); xml = xmlDoc; } insertRow(xml); } } function getNodeContent(xmldoc,key,label) { var na=[],va=[],l; var outstr=''; key=(typeof key=='undefined')?getNodeName(xmldoc,false):key; for (var i=0;i0){ for(j=1;j<=(na.length/1);j++){ q_content = na[i][1]; set_innerHTML(document.getElementById(sd_id), q_content); if(eval_str != ""){eval(eval_str);} } } } function set_innerHTML(obj, html) { obj.innerHTML = html; var scripts = obj.getElementsByTagName("script"); if (scripts) { var cripts=[] for (var i = 0; i < scripts.length; i++) {cripts[i]=scripts[i].text.replace(/(^\s*)|(\s*$)/g, "");} document.write = function (str) { obj.innerHTML += str; } document.writeln = function (str) { obj.innerHTML += str + "
"; } //取得非腳本html代碼 HTMLcodeWithoutScript=obj.innerHTML.replace(//igm,"?").split("?") //obj.innerHTML=HTMLcodeWithoutScript; //向目標元素寫入第一段腳本之前的html內容 var HTMLstr = ""; for(var p = 0; p < HTMLcodeWithoutScript.length; p++){ if(p < HTMLcodeWithoutScript.length-1){ HTMLstr = HTMLstr + HTMLcodeWithoutScript[p]+"?"; }else{ HTMLstr = HTMLstr + HTMLcodeWithoutScript[p]; } } //obj.innerHTML=HTMLstr; for (var i = 0; i < cripts.length; i++) { script = cripts[i] if (cripts[i].src) { script = document.createElement("script"); script.src = cripts[i].src; script.defer = true; script.type = cripts[i].type; var head = document.getElementsByTagName("head").item(0); head.appendChild(script); } else if (script.substr(0, 4) == "