1.eg.在a.js中引入giftMsg.js,这样所有需要giftMsg.js的页面就不需要在引入giftMsg.js了。


var basePath = window.location.href.split("//")[0]+"//"+window.location.host+"/";

url = basePath + "resources/js/giftMsg.js";

$("body").append('<script type="text/javascript" src="' + url + '"></script>');


2.这样也行:

document.write("<script type=\"text/javascript\" src=\"http://code.jquery.com/jquery-1.4.1.js\"></script>");