欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

网站商务通openZoosUrl函数详解

网站商务通openZoosUrl函数详解

前面的文章中已经为大家介绍了 商务通核心函数库解密格式化后的代码 ,那么今天就带大家详细的分析一下商务通中使用频率最高的一个函数openZoosUrl,openZoosUrl函数的作用是打开商务通对话窗口。openZoosUrl函数完整代码如下,我们可以发现其包含两个参数url和data。我们通常在网站中这样使用openZoosUrl函数:

<a href="javascript:;" onclick="openZoosUrl();">点击咨询</a>

或者

<a href="javascript:;" onclick="openZoosUrl('chatwin','&e=banner');">点击咨询</a>

通过分析openZoosUrl的代码,我们可以发现代码中是对参数和一些变量的判断,然后拼接出一个对话窗口的链接,其中包含一些商务通信息,如访客的唯一ID,来路url以及说明信息,相信具有一定JS基础的朋友都能够看懂。

 

复制代码代码如下:
function openZoosUrl(url, data) {
    if (typeof(openZoosUrl_UserDefine) == 'function') {
        if (openZoosUrl_UserDefine()) return
    };
    if (typeof(LR_istate) != 'undefined') {
        LR_istate = 3
    }
    var lr_url1 = url;
    if (typeof(LR_opentimeout) != 'undefined' && typeof(LR_next_invite_seconds) != 'undefined') LR_next_invite_seconds = 999999;
    if (url == 'sendnote') {
        url = LR_sysurl + 'LR/Chatwin2.aspx?siteid=' + LR_websiteid + '&cid=' + LR_cid + '&sid=' + LR_sid + '&lng=' + LR_lng + '&p=' + escape(location.href) + lr_refer5238()
    } else {
        url = ((LR_userurl0 && typeof(LR_userurl) != 'undefined') ? LR_userurl: (LR_sysurl + 'LR/Chatpre.aspx')) + '?id=' + LR_websiteid + '&cid=' + LR_cid + '&lng=' + LR_lng + '&sid=' + LR_sid + '&p=' + escape(location.href) + lr_refer5238()
    }
    if (typeof(LR_UserSSL) != 'undefined' && LR_UserSSL && url.charAt(4) == ':') url = url.substring(0, 4) + 's' + url.substring(4, url.length);
    if (!data) {
        if (typeof(LR_explain) != 'undefined' && LR_explain != '') {
            url += '&e=' + escape(escape(LR_explain))
        } else if (typeof(LiveAutoInvite1) != 'undefined') {
            url += '&e=' + escape(escape(LiveAutoInvite1))
        }
    }
    if (typeof(LR_username) != 'undefined') {
        url += '&un=' + escape(LR_username)
    }
    if (typeof(LR_userdata) != 'undefined') {
        url += '&ud=' + escape(LR_userdata)
    }
    if (typeof(LR_ucd) != 'undefined') {
        url += '&ucd=' + escape(LR_ucd)
    }
    if (data) url += data;
    url += '&d=' + new Date().getTime();
    if (lr_url1 == 'fchatwin') {
        LR_ClientEnd = 0;
        window.location = url + '&f=1';
        return
    }
    var oWindow;
    try {
        if (LR_isMobile) {
            window.location = url
        } else if (LR_checkagent('opera|safari|se 2.x')) {
            oWindow = window.open(url)
        } else {
            oWindow = window.open(url, 'LRWIN_' + LR_websiteid, 'toolbar=no,width=630,height=435,resizable=yes,location=no,scrollbars=no,left=' + ((screen.width - 630) / 4) + ',top=' + ((screen.height - 435) / 4))
        }
        if (oWindow == null) {
            LR_ClientEnd = 0;
            window.location = url;
            return
        }
        oWindow.focus()
    } catch(e) {
        if (oWindow == null) {
            LR_ClientEnd = 0;
            window.location = url
        }
    }
}

 

普通分类: