復制代碼 代碼如下:
(function (clover) {
clover.loadScript = function loadScript(url, callback) {
var heads = document.getElementsByTagName('head');
if (heads.length == 0) {
alert("page must have one head element");
}
var head = heads[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
// most browsers
script.onload = callback;
// IE 6 & 7
script.onreadystatechange = function () {
if (this.readyState == 'complete') {
callback();
}
}
head.appendChild(script);
}
})(window.clover = window.clover || {});
// sample
// clover.loadScript("http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js");