Notice: Undefined index: HTTP_ACCEPT_ENCODING in C:\server\web\www.showyounger.com\s-system.php on line 2
动态加载JS、CSS | 小样儿(ShowYounger)
小样儿,顶呱呱!!![http://www.showyounger.com]
-
-
-
- var jsCssLoadRun = function(o) {
- var count = 0;
- var scriptTag, linkTag;
- var scriptFiles = o.js;
- var cssFiles = o.css;
- var head = document.getElementsByTagName('head')[0];
-
- for ( var k = 0; k < cssFiles.length; k++) {
- linkTag = document.createElement('link');
- linkTag.type = 'text/css';
- linkTag.rel = 'stylesheet';
- linkTag.href = cssFiles[k];
- head.appendChild(linkTag);
- }
-
- for (k = 0; k < scriptFiles.length; k++) {
- scriptTag = document.createElement('script');
- scriptTag.type = 'text/javascript';
- scriptTag.charset = 'utf-8';
- scriptTag.src = scriptFiles[k];
- head.appendChild(scriptTag);
- if (typeof o.callback == "function") {
- if (scriptTag.readyState) {
- scriptTag.onreadystatechange = function() {
- if (scriptTag.readyState == "loaded"
- || scriptTag.readyState == "complete") {
- count++;
- if (count == scriptFiles.length)
- o.callback.call();
- }
- };
- } else {
- scriptTag.onload = function() {
- count++;
- if (count == scriptFiles.length)
- o.callback.call();
- };
- }
- }
- }
-
- if (scriptFiles.length == 0) {
- o.callback.call();
- }
- };
-
- jsCssLoadRun({js:['a.js'],css:['a.css'],callback:function(){alert('a');}});