/********************************************************** 说明:跨域请求数据Javascript组件
----------------------------------------------------------
add by OceanHo 2015-4-13 18:18:14
**********************************************************/
; (function (window, undefined) { var _ap = function () {
}, _asyncID = 2048, _asyncType = "asynctype", _version = "1.5.0", _cbKey = "cb", _cb = ""; function addSc(url, cbAndParam) {
var script = createSc();
script.setAttribute("src", url + "?" + cbAndParam);
window.document.getElementsByTagName("head")[0].appendChild(script);
}; function delSc(id) {
var scripts = getSc();
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].attributes["id"]) {
if (parseInt(scripts[i].attributes["id"].value) === parseInt(id)) {
remove(scripts[i]);
}
}
}
}; function remove(script) {
if ((script) && (script.parentNode)) {
script.parentNode.removeChild(script);
}
}; function clearSc() {
var scripts = getSc();
for (var i = 0; i < scripts.length; i++) {
remove(scripts[i]);
}
}; function getSc() {
var s1 = [];
var scripts = window.document.getElementsByTagName("script");
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].attributes["async"]) {
if (scripts[i].attributes["async"].value === _asyncType) {
s1.push(scripts[i]);
}
}
}
return s1;
}; function createSc() { _asyncID++;
var script = window.document.createElement("script");
script.setAttribute("id", _asyncID);
script.setAttribute("async", _asyncType);
script.setAttribute("type", "text/javascript"); script.onload = script.onreadystatechange = function () { if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") { delSc(this.attributes["id"].value); script.onload = script.onreadystatechange = null;
}
}
return script;
} function waitDel(id, interval) {
window.setInterval(delSc(id), interval);
}; _ap.fn = _ap.prototype = {
constructor: _ap,
version: _version,
init: function (arg) {
return new _ap().constructor;
}, get: function (url, cbk, cb, param) {
if (!cb) cb = _cb;
if (!cbk) cbk = _cbKey;
var qs = this.map(',', param);
addSc(url, _cbKey + "=" + cb + "&" + qs);
}, getEasy: function (url, cb, param) {
if (!cb) cb = _cb;
var qs = this.map(',', param);
addSc(url, _cbKey + "=" + cb + "&" + qs);
}, getCustom: function (url, param) {
addSc(url, this.map(',', param));
}, map: function (split, params) {
var str, strs = [];
if (typeof params != "string") {
params = eval(params);
for (var p in params) {
strs.push(p + "=" + params[p])
}
str = strs.join(split);
} else {
str = param;
}
return str;
},
clear: function () { clearSc(); }
}; _ap.fn.init.prototype = _ap.fn; window.CrossLoad = _ap.fn.init(); })(window); // 使用 、
<script>
window.CrossLoad.getEasy("https://www.oceanho.com/common/chat/v2","ReciveMessageHandler",{}) function ReciveMessageHandler(msg){ }
</script>