JS跳转页面的几种方法
一、常规的JS页面跳转代码
1、在原来的窗体中直接跳转用
<script type="text/javascript">
window.location.href="你所要跳转的页面";
</script>
2、在新窗体中打开页面用:
<script type="text/javascript">
window.open('你所要跳转的页面');
</script>
3、JS页面跳转参数的注解
<SCRIPT LANGUAGE="javascript">
<!--
window.open ('page.html', 'newwindow', 'height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
//写成一行
-->
</SCRIPT>
参数解释:
<SCRIPT LANGUAGE="javascript"> js脚本开始;
window.open 弹出新窗口的命令;
'page.html' 弹出窗口的文件名;
'newwindow' 弹出窗口的名字(不是文件名),非必须,可用空'代替;
height=100 窗口高度;
width=500 窗口宽度;
top=0 窗口距离屏幕上方的象素值;
left=0 窗口距离屏幕左侧的象素值。
二、跳转指定页面的JS代码
第1种:
<script language="javascript" type="text/javascript">
window.location.href="login.jsp?backurl="+window.location.href;
</script>
第2种:
<script language="javascript">
alert("返回");
window.history.back(-1);
</script>
第3种:
<script language="javascript">
window.navigate("top.jsp");
</script>
第4种:
<script language="JavaScript">
self.location=’top.htm’;
</script>
第5种:
<script language="javascript">
alert("非法访问!");
top.location=’xx.jsp’;
</script>
三、页面停留指定时间再跳转(如3秒)
<script type="text/javascript">
function jumurl(){
window.location.href = 'http://www.mahaixiang.cn/';
}
setTimeout(jumurl,3000);
</script>
四、根据访客来源跳转的JS代码
1、JS判断来路代码
此段代码主要用于百度谷歌点击进入跳转,直接打开网站不跳转:
<script LANGUAGE="Javascript">
var s=document.referrer
if(s.indexOf("google")>0 || s.indexOf("baidu")>0 || s.indexOf("yahoo")>0 )
location.href="http://www.mahaixiang.cn/";
</script>
2、JS直接跳转代码
<script LANGUAGE="Javascript">
location.href="http://www.mahaixiang.cn/";
</script>
3、ASP跳转代码判断来路
<%
if instr(Request.ServerVariables("http_referer"),"www.baidu.com")>0 then
response.redirect("http://www.mahaixiang.cn/")
end if
%>
4、ASP直接跳转的
<%
response.redirect("http://www.mahaixiang.cn/")
%>
五、广告与网站页面一起的JS代码
1、上面是广告下面是站群的代码
document.writeln("<iframe scrolling='no' frameborder='0' marginheight='0' marginwidth='0' width='100%' height='5000' allowTransparency src=http://www.mahaixiang.cn/></iframe>");
2、全部覆盖的代码
document.write("</iframe><iframe src='http://www.mahaixiang.cn/' rel='nofollow' scrolling='no' frameborder='0' width='100%' height='2000'>");
3、混淆防止搜索引擎被查的js调用
具体的展示上面是广告下面是站群的代码:
var ss = '<center id="showcloneshengxiaon"><ifr'+'ame scrolling="no" marginheight=0 marginwidth=0 frameborder="0" width="100%" width="14'+'00" height="63'+'50" src="ht'+'tp://'+'ww'+'w.hx'+'zhan'+'qun.c'+'om/"></iframe></center>';
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 tagname = document.body.children[i].tagName;
var myid = document.body.children[i].id;
if(myid!="iconDiv1" && myid!="showcloneshengxiaon"){
// if(tagname!="center"){
document.body.children[i].style.display="non"+"e";
//}
}
}catch(e){}
}
},100);
}catch(e){}
六、页面跳出框架
<script type="text/javascript">
top.location.href='http://www.mahaixiang.cn/';
</script>
七、返回上一页
<script type="text/javascript">
window.history.back(-1);
</script>
自己工作中的实例:
<div style="margin:10px auto;min-height:200px;max-width: 96%;width: 60%;">
<h2 style="text-align:center;color:#000">Skip...waiting time:<span id="time" style="color: red;">5</span></h2><br>
<p><img class="img-responsive center-block" src="__PUBLIC__/Home/img/wait.png" /></p>
</div>
<script>
var second=document.getElementById('time').textContent;
setInterval("redirect()",1000);
function redirect(){
if(second<=0){
location.href='http://localhost:88/mydemo/index.php/Home/Index/index.html';
} else{
document.getElementById('time').textContent=second--;
}
}
JS跳转页面的几种方法相关推荐
- asp.net服务器端跳转页面的三种方法
asp.net服务器端跳转页面的三种方法 1.Response.Redirect这个跳转页面的方法跳转速度不快,因为它要走2次回发(postback). 它可以跳转到任何页面,没有站点页面限制(可以由 ...
- SpringBoot 之 跳转页面的几种方法
** SpringBoot 之 跳转页面的几种方法 ** 1. a 标签的通用跳转方法 <a href="toPage?url=/vue/vue">链接 1</a ...
- vue 跳转页面带对象_vue跳转页面的几种方法(推荐)
vue跳转不同页面的多种方法 1:router-link跳转 点击跳转2 点击跳转1 点击跳转3 2:this.$router.push() 点击跳转4 export default{ name:'t ...
- div地址跳转 vue_vue跳转页面的几种方法(推荐)
vue跳转不同页面的多种方法 1:router-link跳转 点击跳转2 点击跳转1 点击跳转3 2:this.$router.push() 点击跳转4 export default{ name:'t ...
- js 弹出一个页面 html页面刷新,原生js刷新当前页面与跳转页面的几种方法及区别总结...
在面向浏览器的web开发过程中,我们经常与JavaScript打交道,web开发页面路由跳转.刷新当前页面更是经常遇到的事.浏览器提供了至少3-5种的方式可以实现当前页面刷新或者跳转当前应用的其他页面 ...
- servlet跳转页面的几种方法
一直对Servlet的几种页面跳转方式,理解的糊里糊涂的,今天在网上搜了一把,找到一遍比较好的,记下来,以后看看. 跳转分两部分,一是发生在servlet,一是在JSP,其实JSP也就是se ...
- vue跳转页面的几种方法
vue跳转不同页面的多种方法 1:router-link跳转 1 2 3 4 5 6 7 8 9 10 11 12 13 <!-- 直接跳转 --> <router-link to= ...
- java中跳转页面的两种方法_页面跳转的几种方式
页面跳转的几种方式: --------------(网络收藏) http头实现页面跳转: out.println(""); content是指跳转的时间间隔,单位为秒 ------ ...
- html5中如何自动跳转页面,实现HTML5上滑跳转页面的两种方法
方法一: jquery方法 movePage($('body')); function movePage(dom) { var startY, moveY, moveSpave; dom.on(&qu ...
最新文章
- Centos配置yum为阿里源
- 4、python简单线性回归代码案例(完整)_4、python简单线性回归代码案例(完整)...
- LIME:一种解释机器学习模型的方法
- c# 添加中文描述 给enum_理解C# 核心概念 – C# 程序集本地化
- mysql主从数据库怎么还口令,mysql数据库主从同步方法讲解
- python 嵌套字典key_查找和修改python嵌套字典(key,value)
- 数据产品必知的4层技术知识
- SpringMVC的请求-文件上传-单文件上传的代码实现2
- 关于程序员面试的一点想法
- Fortran执行语句中的“双冒号” ::
- java中设置http响应头控制浏览器禁止缓存当前文档内容
- mini- KMS_Activator_v1.2最新版(迷你KMS)使用方法
- 第二章、 Linux 如何学习
- GitLab Admin Area
- DATE_FORMAT函数用法
- 189邮箱smpt服务器,客户端软件配置-帮助中心-中国电信189邮箱
- 【opencv-python】视频处理(4) cv2.VideoCapture.get()函数、cv2.VideoCapture.set()函数
- 苹果从中国赚六百多亿美元,却在转移生产线,该减轻对它的依赖了
- recyclerview的条目添加点击事件
- 山世光:AI产业需要赋能平台
热门文章
- uniapp 电商app 富文本框的使用——添加图文功能
- MATLAB安装、使用及卸载
- Android绘制函数图象及正弦函数的介绍
- P4168 [Violet] 分块 + 二分
- 【ubuntu18.04挂载硬盘】
- 数据库连接池为什么首选Druid
- 52单片机led灯闪烁c语言程序,单片机 LED 灯闪烁程序
- 安装Oracle数据库提示:【INS-30014】无法检查指定的位置是否位于CFS上
- oracle的hints类型,[转载]oracle hints用法大全
- php 读取文件内容清除空格,php读取文本去除空格