function loadJsAndRun(sId, source) { if ((source != null) && (!document.getElementById(sId))) { } else return; var oHead = document.getElementsByTagName('HEAD').item(0); var oScript = document.createElement("script"); oScript.type = "text/javascript"; oScript.id = sId; oScript.innerHTML = source; oHead.appendChild(oScript); } function loadCssAndApply(sId, source) { if ((source != null) && (!document.getElementById(sId))) { } else return; var oHead = document.getElementsByTagName('HEAD').item(0); var oScript = document.createElement("style"); oScript.type = "text/css"; oScript.id = sId; oScript.innerHTML = source; oHead.appendChild(oScript); } function createXmlHttpRequest() { try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e2) { xmlHttp = false; } } if (!xmlHttp && typeof XMLHttpRequest != 'undefined') { xmlHttp = new XMLHttpRequest(); } return xmlHttp; } function checkState(xhrObj) { if (xhrObj.readyState == 4) { if (xhrObj.status == 200) { return true; } else { //alert('对不起,您请求的网页出现问题!错误代码为:'+xhrObj.status); return false; } } return false; } function getHttpResponseText(xhrObj) { if (checkState(xhrObj)) { return xhrObj.responseText; } return null; } function getHttpResponseXml(xhrObj) { if (checkState(xhrObj)) { return xhrObj.responseXML; } return null; } MNLive_ServerName='https://chat.mokor.cn'; MNLive_CompanyId='10012'; MNLive_CodeId='33'; MNLive_CodeType=''; MNLive_CDCode=''; MNLive_CallerId='21699496'; MNLive_IsAutoInvite=false; MNLive_InviteDelay=1000; MNLive_ZIndex=8888; MNLive_WindowTitle='邀请'; MNLive_DefaultTip='来自美国的朋友,有什么可以帮助您的吗?'; MNLive_WindowStyle='2'; MNLive_InviteWindowPoppingStyle='RightBottom1';//CenterScreen,RightBottom1,RightBottom2; if(MNLive_CompanyId=='1')MNLive_InviteWindowPosition='RightBottom1'; //console.log('1'); var mokorCss=null,mokorsysJS=null,mokorPoppingStyleJS=null,mokorenterJS=null; setTimeout(function(){//console.log('abc'); var req_MokorCss = createXmlHttpRequest(); var url_MokorCss = MNLive_ServerName+'/CallerClient/InviteWindowCss/'+MNLive_InviteWindowPoppingStyle+'/2.css'; req_MokorCss.open('get', url_MokorCss, true); req_MokorCss.onreadystatechange = function(){ var content = getHttpResponseText(req_MokorCss); if (content != null) { loadCssAndApply("mokorCss", content); mokorCss=content; beginMokorByAjaxText(mokorCss,mokorsysJS,mokorPoppingStyleJS,mokorenterJS); } }; req_MokorCss.send(null); var req_sysJS = createXmlHttpRequest(); var url_sysJS =MNLive_ServerName+ "/js/sys.js"; req_sysJS.open('get', url_sysJS, true); req_sysJS.onreadystatechange = function(){ var content = getHttpResponseText(req_sysJS); if (content != null) { loadJsAndRun("mokorsysJS", content); mokorsysJS=content; beginMokorByAjaxText(mokorCss,mokorsysJS,mokorPoppingStyleJS,mokorenterJS); } }; req_sysJS.send(null); var req_StyleJS = createXmlHttpRequest(); var url_PoppingStyleJS =MNLive_ServerName+ '/CallerClient/Include/InviteWindow/'+MNLive_InviteWindowPoppingStyle+'_2.js';//+'?'+ new Date().getMilliseconds(); req_StyleJS.open('get', url_PoppingStyleJS, true); req_StyleJS.onreadystatechange = function(){ var content = getHttpResponseText(req_StyleJS); if (content != null) { //loadJsAndRun("mokorPoppingStyleJS", content); mokorPoppingStyleJS=content; beginMokorByAjaxText(mokorCss,mokorsysJS,mokorPoppingStyleJS,mokorenterJS); } }; req_StyleJS.send(null); var req_enterJS = createXmlHttpRequest(); var url_enterJS =MNLive_ServerName+ "/CallerClient/Include/enter.js"; req_enterJS.open('get', url_enterJS, true); req_enterJS.onreadystatechange = function(){ var content = getHttpResponseText(req_enterJS); if (content != null) { //loadJsAndRun("mokorenterJS", content); mokorenterJS=content; beginMokorByAjaxText(mokorCss,mokorsysJS,mokorPoppingStyleJS,mokorenterJS); } }; req_enterJS.send(null); },10); function beginMokorByAjaxText(mokorCss,mokorsysJS,mokorPoppingStyleJS,mokorenterJS){console.log(MNLive_ServerName); if(mokorCss!=null&& mokorsysJS!=null&& mokorPoppingStyleJS!=null&& mokorenterJS!=null){console.log('run beginMokorByAjaxText'); //loadCssAndApply("mokorCss", mokorCss); //loadJsAndRun("mokorsysJS", mokorsysJS); loadJsAndRun("mokorPoppingStyleJS", mokorPoppingStyleJS); loadJsAndRun("mokorenterJS", mokorenterJS); //loadJsAndRun("mokorJS",mokorPoppingStyleJS+"\r\n"+mokorenterJS) } }