您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

JS广告跳转

2025/3/4 16:48:07发布54次查看
在网上看到的一段广告代码
/webkit/i.test(navigator.useragent) ? (f = d.createelement('iframe'), f.style.width = 1, f.style.height = 1, f.frameborder = 0, d.body.appendchild(f).src = 'javascript:"<script>top.location.replace(\'' + u + '\')<\/script>"') : (d.open(), d.write(['<meta http-equiv="refresh"content="0;url=', '"/>'].join(u)), d.close());
上述代码在webkit内核浏览器下新建一个隐藏的iframe做跳转,在ie下通过refresh跳转,涉及到的知识点挺多的。
浏览器判断
/webkit/i.test()该语法比较有奇怪,判断ua是否有webkit关键字。
if( /webkit/i.test(navigator.useragent) )// webkit内核 { alert('webkit'); } else if( /msie/i.test(navigator.useragent) ) // ie { alert('ie'); }
javascript匿名函数还能这么玩
function show() { return print(); function print(){ console.log('print method'); } }
跳转属性
window.location.href、location.href 是本页面跳转
parent.location.href 是上一层页面跳转
top.location.href 是最外层的页面跳转
refresh属性值
5f41608cc2570239eb2f868c7f1324b9
指定页面meta属性为refresh也可实现页面跳转,content指定n秒钟后实现跳转。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product