开发者

How check if ajax.googleapis.com blocked and use my hosting of jquery?

开发者 https://www.devze.com 2022-12-28 22:28 出处:网络
I use http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js but some compaty may block this site, so in this case I want to use my local version on jquery

I use http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js but some compaty may block this site, so in this case I want to use my local version on jquery /JavaScripts/jquery.min.js开发者_高级运维. How can I do it?


if(typeof(jQuery) === 'undefined'){             
    var scr =   document.createElement('script');
                scr.setAttribute('type', 'text/javascript');
                scr.setAttribute('src', 'http://yourdomain/jquery.min.js');

    document.getElementsByTagName('head')[0].appendChild(scr);
    setTimeout(function(){
        // $(document).ready(); here for instance
    }, 3000);
0

精彩评论

暂无评论...
验证码 换一张
取 消