用户要求根据不同省份的访客自动弹出对应省份的客服。
这样方便客服跟客户的沟通。
下面代码简单修改就可以使用
<?php
function getIpAddress(){
$ipContent = file_get_contents(“http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js”);
$jsonData = explode(“=”,$ipContent);
$jsonAddress = substr($jsonData[1], 0, -1);
return $jsonAddress;
}
$ip_info=json_decode(getIpAddress());$ip_info->province;
?>
<script type=”text/javascript” language=”javascript”>
var city='<?php echo $ip_info->province;?>’; //根据IP地址所有城市跳转到指定页面if(city.indexOf(“山东”)>=0){
window.location.href=”http://shanghai.demo.com/”; }
if(city.indexOf(“广东”)>=0){
window.location.href=”http://shanghai.demo.com/”; }
if(city.indexOf(“上海”)>=0){
window.location.href=”http://shanghai.demo.com/”; }
</script>
然后呢
我直接弹出QQ客服
<?php
function getIpAddress(){
$ipContent = file_get_contents(“http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js”);
$jsonData = explode(“=”,$ipContent);
$jsonAddress = substr($jsonData[1], 0, -1);
return $jsonAddress;
}
$ip_info=json_decode(getIpAddress());$ip_info->province;
if ($ip_info->province==”上海”)
{
echo “<a title=\”在线咨询\” href=\”http://wpa.qq.com/msgrd?v=3&uin=998888&site=qq&menu=yes\” target=\”_parent\”> “;}else {
echo “<a title=\”在线咨询\” href=\”http://wpa.qq.com/msgrd?v=3&uin=9999&site=qq&menu=yes\” target=\”_parent\”> “; }
?>