Last active
December 21, 2015 20:49
-
-
Save tonyc726/6363655 to your computer and use it in GitHub Desktop.
动态加载jQuery并等待载入完毕后回调mainFrom http://www.cbrother.com/html/1266.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
动态加载jQuery并等待载入完毕后回调main | |
Author:McFog | |
*/ | |
_unique_main = function() { | |
//maincode with jquery support | |
}//end of main | |
if(typeof $ != 'function' || typeof $().jquery != 'string') { | |
_unique_doc = document.getElementsByTagName('head')[0]; | |
_unique_js = document.createElement('script'); | |
_unique_js.setAttribute('type', 'text/javascript'); | |
_unique_js.setAttribute('src', "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"); | |
_unique_doc.appendChild(_unique_js); | |
_unique_try2go = function() { | |
if(typeof $ == 'function' && typeof $().jquery == 'string') { | |
clearInterval(_unique_mainIntv); | |
_unique_main(); | |
} | |
} | |
var _unique_mainIntv = setInterval(_unique_try2go, 300); | |
} else { | |
_unique_main(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment