JS判断来路简单问题

go786 2009-09-14 09:47:02
JS判断来路问题,来路域名如果是baidu.com(包括他的所有二级域名)则没有任何反应,如果来路域名非baidu.com,则跳转至g.cn
...全文
121 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
浴火_凤凰 2009-09-14
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 hookee 的回复:]
JScript codeif(document.referrer.indexOf("baidu.com")==-1) location.href="http://www.g.cn";
[/Quote]

支持啊!!!
hookee 2009-09-14
  • 打赏
  • 举报
回复
if(document.referrer.indexOf("baidu.com")==-1) location.href = "http://www.g.cn";
BeenZ 2009-09-14
  • 打赏
  • 举报
回复
写错了,是

if(location.herf.indexOf("baidu.com")==-1) location.herf="g.cn";
go786 2009-09-14
  • 打赏
  • 举报
回复
好像没反应哦?
扁鵲東南飛 2009-09-14
  • 打赏
  • 举报
回复
试试看;
BeenZ 2009-09-14
  • 打赏
  • 举报
回复

var reg=/(baidu.com)/gi;
if(!reg.test(location.herf)) location.herf="g.cn";

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧