添加商务通很简单,只是几行代码的事.把商务通的文件夹swt放在网站的根目录就好,让后在index.php或者footer.php的合适位置.让后在加入以下代码就可以实现商务通的调用了:
<!--you xia xuan fu--> <link href="/swt/css/youf.css" rel="stylesheet"> <script type="text/javascript" src="/swt/css/youf.js"></script> <div id="top"></div> <!--zuo xia xuanfu --> <div id="scrolltriggered"> <div id="inscroll"> <a href="javascript:void()" id="closebox" onclick="document.getElementById('scrolltriggered').style.display='none'">x</a> <form action="http://www.zzhotfun.com/ims/post.php" onsubmit="return validate_form3()" class="mess" method="POST" name="formText" enctype="multipart/form-data"> <h3 class="title" > Get Latest Price </h3> <div class="section section-top"> <p>Hello! Can I help you choose a product?</p> <ul> <li> <input placeholder="Name*" value="" class="txt icon-text-user" type="text" name="name" id="forms_name"/> </li> <li> <input placeholder="E-Mail*:" value="" class="txt icon-text-email" type="text" name="email"/> </li> <li> <textarea placeholder="Message*:" name="message" class="txt" id="forms_message"></textarea> </li> </ul> </div> <div class="section divider section-bottom"> <input type="submit" value="Send Now" class="submitbj" /> </div> </form> </div> </div> <script> function validate_form3(){ var cp=document.getElementById("forms_name").value; var nr=document.getElementById("forms_message").value; if(cp==null||cp==""){alert('The name cannot be empty!');return false} if (nr==null||nr==""){alert('The Message cannot be empty and can not have HTML tags!');return false} if (nr.indexOf("href")>=0){alert('The Message cannot be empty and can not have HTML tags!');return false} if (nr.indexOf("www")>=0){alert('The Message cannot be empty and can not have HTML tags!');return false} if (nr.indexOf("http")>=0){alert('The Message cannot be empty and can not have HTML tags!');return false} if (nr.length<10){alert('Please input more content in Message for our better communication');return false} //alert("Submit is successful, we will contact you as soon as possible, thank you!"); } </script> <!--swt--> <script type="text/javascript" src="/swt/swt.js"></script>
然而,今天我在加商务通时出现了错误,错误结果是整个页面出来之后会全部消失,只剩下商务通js文件里的电话号码.
折腾了好久不知道问题出在那里,经过不断地删除测试,最后判断是div标签的问题.就是标签的id名称重复了,代码里出现了两个id=top的名称.所以只要把商务通的ID名称换掉该问题就可以解决.要注意的是,要同时修改swt文件夹中js代码里的id名称哦!