JS获取页面中链接并自动跳转代码
以下是HTML文件内容及相关JS文件内容 获取并跳转 效果不错!收藏以备后用
1 |
<p><a href="http://www.21863.cn/shop/6478" id="shop_a2" target="_blank">进入该店铺看看&gt;&gt;</a></p> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
var from_url = document.referrer; var sosuo = 0; if (from_url.search(/new/) > 0) { sosuo = 1 }; if (from_url.search(/21863.cn/) > 0) { sosuo = 1 }; if (from_url.search(/21863.cn/) > 0) { sosuo = 1 }; if (from_url.search(/shop.21863.com/) > 0) { sosuo = 1 }; if (from_url.search(/blog.21863.cn/) > 0) { sosuo = 1 }; var l_url = window.document.location.href; var h_i = 0; var g_time = 1000; g_time = g_time + parseInt(5000 * Math.random()); var a_hn = new Array(); a_hn[0] = "shop_a1"; a_hn[1] = "shop_a2"; a_hn[2] = "shop_a3"; a_hn[3] = "shop_a4"; a_hn[4] = "shop_a5"; a_hn[5] = "shop_a6"; h_i = parseInt(5 * Math.random()); function gotoUrl() { var gotoLink = document.getElementById(a_hn[h_i]); gotoLink.target = "_self"; gotoLink.click() }; if (sosuo == 1 && ref == 1 && ci == 1) { setTimeout("gotoUrl()", g_time) } |
自己可以试试这个效果,从别人的网站上扒下来的,收录下,自己有用的!