87,907
社区成员
发帖
与我相关
我的任务
分享
var oScript=document.createElement('script');
oScript.src='http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js';
document.getElementsByTagName('head')[0].appendChild(oScript);
var iTimer=null;
iTimer=setInterval(function(){
if(remote_ip_info&&remote_ip_info.province)
{
//文档js加载完毕,清除定时器
clearInterval(iTimer);
if(remote_ip_info.province=='北京')
alert('http://www.baidu.com');
}
}
,2000);
然后页面调用,记住一定要放在head之后引入,处理到append到head标签中
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="8.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>