- /**
- *
- * Chainable external javascript file loading
- * <a href="http://www.webtoolkit.info/">http://www.webtoolkit.info/
- *
- **/
- var scriptLoader = {
- _loadScript: function (url, callback) {
- var head = document.getElementsByTagName('head')[0];
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.src = url;
- if (callback) {
- script.onreadystatechange = function () {
- if (this.readyState == 'loaded') callback();
- }
- script.onload = callback;
- }
- head.appendChild(script);
- },
- load: function (items, iteration) {
- if (!iteration) iteration = 0;
- if (items[iteration]) {
- scriptLoader._loadScript(
- items[iteration],
- function () {
- scriptLoader.load(items, iteration+1);
- }
- )
- }
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/240420132990.html
来源: http://www.codesnippet.cn/detail/240420132990.html