Re: [ js ] .js include js檔
※ 引述《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
07/18 00:14, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 7 篇):
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章
41
173