js获取当前网址与来路IP 并应用到商务通统计来路
医院网站一般会用到商务通网上预约软件,一个医院会有好多部门科室 可以会共用商务通,会造成商务通绑定域名不够用,这就有了针对需求的自定义商务通。
自定义商务通,无外乎是两三个弹窗,中间左边右边这几个窗口而已,然而写JS实现左右关闭与打开功能。而最终目的就是加链接跳到商务通聊天后台。后台有个功能可以看到访问者是从哪个站来的。现在用自定义商务通实现这个功能,而且还应用了一个IP包来实现获取访问者的IP及所在城市。
自定义商务通代码:
// JavaScript Document document.write('<script language="javascript" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="http://com.zoosnet.net/JS/LsJS.aspx?siteid=COM61101284"></script>'); //统计来路必加 document.write('<link href="http://www.bioaa.cn/jsshare/images/swtdiy.css" type="text/css" rel="stylesheet" />'); //样式 thisTLoc = top.location.href; thisPLoc = parent.document.location; thisTHost = top.location.hostname; thisHost = location.hostname; var www = thisTHost; //获取当前域名信息 var city = returnCitySN.cname; //获取IP所在城市 IP接口在另个JS里面引用 document.write('<div id="RTfloat" ><img id="LRfloater0close" onclick="showswt()" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="http://lwt.zoosnet.net/LR/closeimg/7.gif"><a href="http://www.bioaa.cn/swt/go.php?url='+www+'" target="_blank"><img class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="http://com.zoosnet.net/site/61101284/left_cn.jpg" border=0></a></div>'); //右边图片 可以换 document.write('<div id="fo" ><table id="LR_Tb2" align="center"><tbody><tr><td width="400" valign="bottom"><font >您好,来自'+city+'的朋友</font></td><td width="20" align="right" ><a href="javascript:void(0)" onclick="hideswt()"><img class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="http://com.zoosnet.net/js/rn_Pink/close.gif" border="0"></a> </td></tr><tr><td colspan="2"><table id="LR_Tb3" align="center"><tbody><tr><td><table cellspacing="0" cellpadding="0" id="LR_Tb4" align="center" ><tbody><tr><td rowspan="2" align="center"><img class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="http://com.zoosnet.net/site/61101284/invite_share.jpg"></td><td align="left" valign="top"><div ><div ><div ><a href="http://www.bioaa.cn/swt/go.php?url='+www+'" target="_blank"><img class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="http://www.bioaa.cn/swt/images/01.gif" border="0" align="absmiddle"></a> <a href="http://www.bioaa.cn/swt/go.php?url='+www+'" target="_blank"><img class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="http://www.bioaa.cn/swt/images/02.gif" border="0" align="absmiddle"></a></div></div><iframe scrolling="no" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="" height="0" frameborder="0" width="100%"></div></td></tr><tr><td align=right height=30><table border=0 ><tr><td><a href="javascript:void(0)" onclick="LR_HideInvite();openZoosUrl();return false;"><img class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="http://com.zoosnet.net/js/rn_Pink/a_cn.gif" border=0></a></td><td width=20></td><td><a href="javascript:void(0)" onclick="LR_HideInvite();LR_RefuseChat();return false;"><img class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="http://com.zoosnet.net/js/rn_Pink/r_cn.gif" border=0></a></td><td width=20></td></tr></table></td></tr></table></td></tr></table></td></tr></table></div></iframe></div></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></div>'); //中间图片 也可以换 window.setTimeout("showswt()",5000);//页面加载后延迟多少毫秒显示对话框 function showswt() { $("#RTfloat").fadeOut("slow"); $("#fo").fadeIn("slow"); setTimeout("hideswt()",10000); } function hideswt() { $('#fo').fadeOut("slow"); $('#RTfloat').fadeIn("slow"); //setTimeout("showswt()",10000); } //解决IE6关闭不起作用 $("#close").click( function() { $("#fo").fadeOut('slow'); $("#RTfloat").fadeIn('slow'); return false; }); $("#hide").click( function() { $("#fo").fadeOut('slow'); $("#RTfloat").fadeIn('slow'); return false; });
把上面代码另存为如swt.js文件 再用个JS文件引用
document.write('<script language="javascript" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="http://code.jquery.com/jquery-1.8.1.min.js "></script>');
document.write('<script class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="http://pv.sohu.com/cityjson?ie=utf-8"></script>'); //搜狐IP接口
document.write('<script language="javascript" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="/swt.js"></script>');
上面就可以实现 显示访问者城市 获取网址有什么用呢,在下面:
代码里有这样一段链接
<a href="http://www.bioaa.cn/swt/go.php?url='+www+'" target="_blank"></a>就是把当前页面传值给go.php处理,go.php里代码如下:
<?php $url=$_GET['url']; header("HTTP/1.1 301 Moved Permanently"); //跳转到商务通代码 switch($url){ case zhongjian:header('location:http://com.zoosnet.net/LR/Chatpre.aspx?id=COM61101284&p=zhongjian');break; case qqdibu:header('location:http://com.zoosnet.net/LR/Chatpre.aspx?id=COM61101284&p=qqdibu');break; default: header('location:http://com.zoosnet.net/LR/Chatpre.aspx?id=COM61101284&p='.$url.''); } ?>
这样就可以在商务通后台看到访问者来源网址。
共同学习,写下你的评论
评论加载中...
作者其他优质文章