@seth의 대답은 완전히 옳다,하지만 당신은 당신이로드 된 직후에 제거 할 수 있습니다, 또한 당신이 때을 알고 싶어 할 수는 DOM에 삽입 된 script
요소를 떠날 필요가 없습니다 삽입 된 스크립트는 당신이 할 수있는 예를 들어, 사용할 수 있습니다 :
function loadScript(url, completeCallback) {
var script = document.createElement('script'), done = false,
head = document.getElementsByTagName("head")[0];
script.src = url;
script.onload = script.onreadystatechange = function(){
if (!done && (!this.readyState ||
this.readyState == "loaded" || this.readyState == "complete")) {
done = true;
completeCallback();
// IE memory leak
script.onload = script.onreadystatechange = null;
head.removeChild(script);
}
};
head.appendChild(script);
}
사용법 :
loadScript("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",
function() { alert('jQuery has been loaded.'); });
출처
2009-09-03 21:00:47
CMS
너무 감사합니다! 중대한 도움 – Ronal
당신을 진심으로 환영합니다. – seth
유형이 필요하지 않습니다. (차이가 있습니다) –