Business Pass open conversation window fault tolerant code

Source: Internet
Author: User

In some cases, the page loading business pass JS code failed, resulting in the visitor click the Advisory button can not enter the Business Access dialog window, the following medical template library for everyone to organize a piece of code, you can prevent the business through the load failure caused the visitors cannot open the dialog window this situation occurs.


The complete code is as follows:


<script type= "Text/javascript" >

function Online () {

var e = ' Anniu ';

if (arguments.length = = 1) {

E = encodeURIComponent (arguments[0]);

}

if (typeof Openzoosurl = = "undefined") {

Test please replace this address with your own business address

var url = ' http://test.zoossoft.net/LR/Chatpre.aspx?id=test001&lng=cn&rf1= ' + encodeuricomponent ( Document.referrer);

url = url + ' &e= ' + E + ' &p= ' + encodeuricomponent (location.href);

try{

window.open (URL, ' News ' + (new Date ()). GetTime ());

}catch (e) {

location.href = URL;

}

}else{

Openzoosurl (' Chatwin ', ' &e= ' + e);

}

return false;

}

</script>


Code Usage Instructions:


1, the actual test use, please replace the business address in the code with their own http://test.zoossoft.net/LR/Chatpre.aspx?id=test001


2. Before we add the Open Business Pass Dialog window button on the website, it is generally added as follows:

<a href= "/swt/" > Consulting online expert </a>//How to use page jump

<a href= "javascript:;"//Use the business pass to bring up the dialog window function, the same as below.

<a href= "Javascript:openzoosurl (' Chatwin ', ' &e=zhuanjia ')" > Consulting online expert </a>

If you use the above to provide a fault tolerant code, you only need to modify the connection code to the following:

<a href= "javascript:;" onclick= "Online (' Zhuanjia ')" > consulting on-line expert </a><a href= "Javascript:online (' Zhuanjia ') > Consulting online Experts </a>

Code principle:


The code just makes a judgment, judge whether the Openzoosurl function is defined, Openzoosurl is the function of opening the dialog window with the business pass, if it has been defined that the business pass code is loaded correctly, then we call the business Access function to open the dialog box. If the function is undefined, then the business pass code loading fails, we use the Business Access Dialog window link to open the dialog window, where the above provided code contains the URL to get the address of the route, the current page address of the code, passed to the business to the background, to prevent the loss of track.

Business Pass open conversation window fault tolerant code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.