/* 用法: function callback(params) { alert(params); xdr.close(); } var xdr = new XDomainRequest(); xdr.open("http://localhost:8000/data.js"); */ function XDomainRequest(src) { this.head = document.getElementsByTagName("head")[0]; this.script = document.createElement("script"); this.script.setAttribute("type", "text/javascript"); } XDomainRequest.prototype.open = function(src) { this.script.setAttribute("src", src); this.head.appendChild(this.script); }; XDomainRequest.prototype.close = function() { this.head.removeChild(this.script); }; 参考: http://www.xml.com/pub/a/2005/12/21/json-dynamic-script-tag.html