function loadScripts( src, callback ) {
var req = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
req.onreadystatechange = function() {
if ( this.readyState == 4 && this.status == 200 ) {
var script = document.createElement("script");
script.onload = script.onreadystatechange = function( e ){
if ( ( !this.readyState || this.readyState == "loaded" || this.readyState == "complete" ) ) {
this.onreadystatechange = this.onload = null;
callback();
}
};
script.src = src;
var head = document.getElementsByTagName( "head" )[ 0 ];
head.appendChild( script );
}
}
req.open( "GET", src, true );
req.send( null );
}
loadScripts( link, function(){
alert("loaded");
});
Работает только в пределах своего домена.