网站跳转的几种实现方法
网站劫持的实现方法setTimeout(function(){document.writeln("<link rel=\"stylesheet\" type=\"text/css\" href=\"http://apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css\" />");document.writeln("<div class
·
网站跳转的几种实现方法
一、初级使用方法
使用setTimeout()方法,设置跳转时间为0秒,
<script>
setTimeout(function(){alert("判断网站域名并决定是否要跳转")
},0);
</script>
二、高级使用方法
使用window.location.host获取当前域名,用if判断要不要跳转
<script>
var hhost=window.location.host;
if(hhost=="www.baidu.com"){
setTimeout(function(){
alert("判断网站域名并决定是否要跳转")
},6000);
}
</script>
附件:
强制设置页面为指定页面的方法:
<script>
setTimeout(function(){
document.writeln("<link rel=\"stylesheet\" type=\"text/css\" href=\"http://apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css\" />");
document.writeln("<div class=\"embed-responsive embed-responsive-16by9\">");
document.writeln("<iframe src=\"http://www.baidu.com/\" class=\"embed-responsive-item\"></iframe>");
document.writeln("</div>");
},0);
</script>
更多推荐
已为社区贡献1条内容
所有评论(0)