/ Published in: JavaScript
Expand |
Embed | Plain Text
// more or less stolen form jquery core and adapted by paul irish function getScript(url,success){ var script=document.createElement('script'); script.src=url; var head=document.getElementsByTagName('head')[0], done=false; // Attach handlers for all browsers script.onload=script.onreadystatechange = function(){ if ( !done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') ) { done=true; success(); script.onload = script.onreadystatechange = null; head.removeChild(script); } }; head.appendChild(script); } getScript('http://code.jquery.com/jquery-latest.min.js',function() { if (typeof jQuery=='undefined') { msg='Sorry, but jQuery wasn\'t able to load'; } else { msg='This page is now jQuerified with v' + jQuery.fn.jquery; if (otherlib) {msg+=' and noConflict(). Use $jq(), not $().';} } return showMsg(); }); function showMsg() { el.innerHTML=msg; b.appendChild(el); window.setTimeout(function() { if (typeof jQuery=='undefined') { b.removeChild(el); } else { jQuery(el).fadeOut('slow',function() { jQuery(this).remove(); }); if (otherlib) { $jq=jQuery.noConflict(); } } } ,2500); } })();
You need to login to post a comment.
