Js.txt 1.49 KB
;(function() {
var messagingIframe,
bridge = 'sdk',
CUSTOM_PROTOCOL_SCHEME = 'jscall';
var appId = '%@' ,deviceId='%@';


if (window[bridge]) { return }

// 创建隐藏的iframe
function _createQueueReadyIframe(doc) {
    messagingIframe = doc.createElement('iframe');
    messagingIframe.style.display = 'none';
    doc.documentElement.appendChild(messagingIframe);
}

window[bridge] = {};

window[bridge]['getAppId']=function getAppId(){
//alert('appid='+appId);
    return appId;
};
window[bridge]['getDeviceId']=function getDeviceId(){
    return deviceId;
};

window[bridge]['closeWin'] = function closeWin(uid,nick,sessionKey){
document.location=CUSTOM_PROTOCOL_SCHEME + ':' + arguments.callee.name + ':' + encodeURIComponent(JSON.stringify(arguments));
};
//var methods = ["closeWin(uid,nick,sessionKey)"];
//var methodsWithoutParam =["closeWin"];
//for (var i=0;i<methods.length;i++){
//    var method = methods[i];
//    var methodWithoutParam = methodsWithoutParam[i];
//    var code = "(window[bridge])[methodWithoutParam] = function " + method + " {var fs =CUSTOM_PROTOCOL_SCHEME + ':' + arguments.callee.name + ':' + encodeURIComponent(JSON.stringify(arguments)); messagingIframe.src = fs;alert('closeWin src:'+messagingIframe.src);}";
//    eval(code);
//}

//创建iframe,必须在创建app之后,否则会出现死循环
_createQueueReadyIframe(document);
//通知js开始初始化
//alert('onInjectJsOver='+typeof(onInjectJsOver));
if(typeof(onInjectJsOver)=='function')
    onInjectJsOver();

})();