Re: [ js ] .js include js檔

看板Ajax作者 (wctang)時間17年前 (2008/07/17 21:43), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串3/7 (看更多)
※ 引述《wctang (wctang)》之銘言: : function loadscript(jspath,loaded) { : var s=document.createElement('script'); : s.setAttribute('type','text/javascript'); : s.setAttribute('src',jspath); : if(loaded){ : if(s.addEventListener){ : s.addEventListener('load',loaded,false); : }else if(document.all){ : s.onreadystatechange=function(){if(this.readyState==='loaded'){loaded();}} : } : } : document.getElementsByTagName('head')[0].appendChild(s); : } : loadscript('http://jquery/addrss.js',function(){ : alert($); : }); 另一個方法... 把 jquery-1.2.6.pack.js 放到自己 server 上... 然後用 xmlhttprequest 來 load... var xmlhttp=false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) // JScript gives us Conditional compilation, we can cope with old IE versions. // and security blocked creation of the objects. try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @end @*/ if (!xmlhttp && typeof XMLHttpRequest!='undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp=false; } } if (!xmlhttp && window.createRequest) { try { xmlhttp = window.createRequest(); } catch (e) { xmlhttp=false; } } xmlhttp.open("GET","jquery-1.2.6.pack.js",true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { eval(xmlhttp.responseText); alert($); } } xmlhttp.send(null); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.127.126.90

07/18 00:14, , 1F
Sorry = =" 是我耍笨了,addEventListener的方法可以用
07/18 00:14, 1F
文章代碼(AID): #18Vqo96j (Ajax)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 7 篇):
2
10
文章代碼(AID): #18Vqo96j (Ajax)