tonyc726
8/28/2013 - 8:41 AM

动态加载jQuery并等待载入完毕后回调mainFrom http://www.cbrother.com/html/1266.html

动态加载jQuery并等待载入完毕后回调mainFrom http://www.cbrother.com/html/1266.html

/*
动态加载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();
}