用Js脚本实现页面跳转

合集下载

实现网页页面跳转的几种方法(meta标签、js实现、php实现)

实现网页页面跳转的几种方法(meta标签、js实现、php实现)

实现网页页面跳转的几种方法(meta标签、js实现、php实
现)
今天总结了几种页面跳转的方法,分别是用meta标签实现、用javascript实现、用php实现,下面就来一一分享一下吧。

1、meta标签实现
只需在head里加上下面这一句就行了,在当前页面停留0.1秒后跳转到目标页面
复制代码代码如下:
<meta http-equiv="refresh" content="0.1; url=/">
2、Javascript实现
方法一:
这个方法比较常用
复制代码代码如下:
window.location.href = "/";
方法二:
复制代码代码如下:
self.location = "/";
方法三:
复制代码代码如下:
top.location = "/";
方法四:
只对IE系列浏览器有效,实用性不大
复制代码代码如下:
window.navigate("/");
3、php实现
复制代码代码如下:
<?php
header("Location: /");
>
Ok,以上就是今天总结的几种页面跳转的方法了。

JS实现页面跳转与刷新的方法汇总

JS实现页面跳转与刷新的方法汇总

JS实现页⾯跳转与刷新的⽅法汇总window.location(.href)="URL"其实 .href 可以省略window.location 和window.location.href 实现的效果是⼀样的例如:window.location = ""window.location.href = 上⾯两种⽅法都可以从当前页⾯跳转到⽬标页⾯不同之处在于window.location 返回的是对象,如果没有.href,它会默认参数就是hrefwinodw.location.assign("URL")这个⽅法和上⾯的⽅法差不多⽤法:winodw.location.assign()window.location.replace("URL")如果⽤window.location.replace("") 实现跳转页⾯, 它和上⾯⽅法的区别在于它跳转后不会保存跳出页⾯的信息.所以如果使⽤ history 历史返回按钮是⽆效的它的效果类似于在⽹页上点击右键, 在新窗⼝打开或新标签页打开.⽽window.location.href 实现的效果是在页⾯上点击⽬标链接, 然后可以点击历史返回按钮, 返回到之前页⾯。

历史页跳转下⾯的两种⽅法都可以实现返回历史页,相当于点了页⾯左上⾓的返回按钮window.history.back();window.history.go(-1);back和go⾥⾯都可以放数值例如:⾥⾯放上 -1 意思就是返回上⼀级,⾥⾯放上 -2 就是返回上上级,以此类推⽽且⾥⾯还可以放上指定的路由路径,⽐如window.history.go('../routes/admin/'); 这样可以跳转到指定的路由模块meta refresh如果⽤户浏览器禁⽤了javascript, 那么可以⽤meta refresh来实现⾃动跳转:<noscript><meta http-equiv="refresh" content="0;URL=/"></noscript>如果要实现 JS ⾃动跳转,可以加个定时器:setTimeout(function(){ ... }, 1000);重新加载本页如果你的代码逻辑执⾏完了,想要重新加载页⾯的话,可以⽤这两种⽅法:window.location.reload()window.location.replace()这两种⽅法都可以重新加载本页,但是replace()可以导向另外⼀个URL例如:window.location.replace("")window.navigate('URL')window.navigate('URL')这个⽅法是只针对IE的,不适⽤于⽕狐等其他浏览器,在HTML DOM Window Object中,根本没有列出window.navigate这个⽅法,所以这个⽅法尽量少⽤,遗忘最好。

常用的JS页面跳转代码调用大全

常用的JS页面跳转代码调用大全

常⽤的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 = '/'; } 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="/"; </script>2、JS直接跳转代码<script LANGUAGE="Javascript"> location.href="/"; </script>3、ASP跳转代码判断来路<% if instr(Request.ServerVariables("http_referer"),"")>0 then response.redirect("/") end if %>4、ASP直接跳转的<% response.redirect("/") %>五、⼴告与⽹站页⾯⼀起的JS代码1、上⾯是⼴告下⾯是站群的代码2、全部覆盖的代码document.write("</iframe><iframe src='/' 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='/'; </script>七、返回上⼀页<script type="text/javascript"> window.history.back(-1); </script>。

JS动态添加的div点击跳转到另一页面实现代码

JS动态添加的div点击跳转到另一页面实现代码

JS动态添加的div点击跳转到另⼀页⾯实现代码 div调⽤函数跳转:var obj = document.getElementById('id');obj.onclick=function(){window.location.href="跳转的地址" rel="external nofollow" ;}源⽂件:<!DOCTYPE html><html><head><title>⾸页推荐页⾯</title><meta name="author" content="Chunna.zheng"/><meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8"/><style type="text/css">div.recommendclass {width: 100%;height: 60px;line-height: 60px;vertical-align: middle;font-size: 18px;text-align: center; /*⽂字⽔平居中对齐*/background-color: #f5f5f5;}.mall_contentChild1Class {display: inline;width: 40%;height: 100px;background-color: #f5f5f5;}.mall_contentChild2Class {display: inline;width: 60%;height: 100px;float: right;position: relative;background-color: #f5f5f5;}.mall_contentChild2BottomClass {display: table-cell;width: 90%;vertical-align: bottom;position: absolute;left: 5px;bottom: 5px;background-color: #f5f5f5;}.mall_Child2TextLeftClass {line-height: 16px;vertical-align: bottom;background-color: #f5f5f5;}.mall_Child2TextRightClass {float: right;color: #f3b041;font-size: 25px;line-height: 26px;vertical-align: bottom;background-color: #f5f5f5;}.news_title {display: block;font-size: 18px;vertical-align: center;background-color: #f5f5f5;}.news_message {display: block;font-size: 14px;vertical-align: center;background-color: #f5f5f5;}.news_time {display: block;font-size: 12px;vertical-align: bottom;position: absolute;bottom: 5px;right: 5px;background-color: #f5f5f5;}</style></head><body style="margin: 0; padding: 0 "><div id="mall_news" class="recommendclass">新闻咨讯</div><div id="news_content" style="background-color:#f5f5f5"></div><script>var Shu = 2;var df = document.createElement("div");for (var i = 0; i <= Shu; i++) {var oDiv = document.createElement("div");var divChild1 = document.createElement("div");divChild1.className = 'mall_contentChild1Class';var img = document.createElement("img");img.style.width = "130px";img.style.height = "100px";img.src = 'ic_mall_good_stuff.jpg';divChild1.appendChild(img);oDiv.appendChild(divChild1);var divChild2 = document.createElement("div");divChild2.className = 'mall_contentChild2Class';var text1 = document.createElement("span");text1.className = 'news_title';text1.innerHTML = "我是标题";divChild2.appendChild(text1);var bottomDiv = document.createElement("div");var textLeft = document.createElement("span");textLeft.className = 'news_message';textLeft.innerHTML = "我是内容";bottomDiv.appendChild(textLeft);var textRight = document.createElement("span");textRight.className = 'news_time';textRight.innerHTML = "2017.09.23";bottomDiv.appendChild(textRight);divChild2.appendChild(bottomDiv);oDiv.appendChild(divChild2);//添加点击事件oDiv.onclick = function(){window.location.href="file:///android_asset/news.html" rel="external nofollow" ;}df.appendChild(oDiv);}document.getElementById("news_content").appendChild(df);</script></body></html>总结以上所述是⼩编给⼤家介绍的JS动态添加的div点击跳转到另⼀页⾯实现代码,希望对⼤家有所帮助,如果⼤家有任何疑问请给我留⾔,⼩编会及时回复⼤家的。

js实现页面跳转重定向的几种方式

js实现页面跳转重定向的几种方式
这篇文章主要介绍了微信小程序如何调用新闻接口实现列表循环文中通过示例代码介绍的非常详细对大家的学习或者工作具有一定的参考学习价值需要的朋友可以参考下
js实 现 页 面 跳 转 重 定 向 的 几 种 方 式
第一种: 复制代码 代码如下:
<script language="javascript"type="text/javascript"> window.location.href=""; </script>
第四种: 复制代码 代码下:
<script language="JavaScript"> self.location=''; </script>
第五种: 复制代码 代码如下:
<script language="javascript"> alert("非法访问!"); top.location=''; </script>
第二种: 复制代码 代码如下:
<script language="javascript"> alert("返回"); window.history.back(-1); </script>
第三种: 复制代码 代码如下:
<script language="javascript"> window.navigate(""); </script>

网页跳转代码,实现自动跳转到指定页面的方法

网页跳转代码,实现自动跳转到指定页面的方法

这种方法容易让搜索引擎读取,目前用的非常少了,因为跳转的页面本身没有实际作用,会视为桥页,垃圾页面,所以方法,是插入JS代码,来控制浏览器进行网页跳转,
<!--脚本开始-->
<script language="javascript" type="">
}
}countDown(6);</script>
</div>
<!--脚本结束-->
把上边的JS代码插入到网页BODY内,这样在6秒过后,浏览器自然就会跳转到/上面,里边只需要设置时间和你要跳转的网址就可以,这种代码搜索引擎并不能读取他的作用,因此在网站优化的过程中使用比较好。
在我们做网站的时侯,经常会给客户做个FLASH首页,或者开头有一个片头的页面,然后经过几秒钟自动跳转,打开网站主页,虽然这种特效已经很少用了,但是有的时侯还是会用在别的场合,插入网页跳转代码,就可以让访客不进行任何操作,自动打开我们指定好的页面,下面,我们给大家介绍两种实现这种效果的方法。
function countDown(secs){
tiao.innerText=secs;
if(--secs>0){
setTimeout("countDown("+secs+")",2000);
}else{
location.href="/"
第一种方法,比较简单,很早以前,大家都会使用的html代码,在head区域内插入 <meta http-equiv="refresh" content="10;url=/">,这段代码告诉浏览器,过10秒就自动刷新页面,打开济宁网站建设公司/这个网页。

gotopage方法

gotopage方法

gotopage方法
gotopage方法是一种常见的web开发方法,用于在页面上跳转到指定的URL或页面位置。

该方法可以在JavaScript中使用,通常通过JavaScript事件监听器触发。

例如,当用户单击一个链接或按钮时,可以使用gotopage方法将页面跳转到一个新的URL或页面位置。

该方法的语法非常简单,通常只需要传递一个参数,即目标URL 或页面位置。

例如,在JavaScript中使用gotopage方法实现页面跳转的代码如下:
function gotoPage(url) {
window.location.href = url;
}
在上述代码中,gotoPage函数将传递的url参数设置为window.location.href属性,从而将页面跳转到指定的URL。

除了直接跳转到指定的URL,gotopage方法还可以用于滚动到页面的指定位置。

例如,以下代码使用gotopage方法将页面滚动到页面顶部:
function scrollToTop() {
window.scrollTo(0, 0);
}
在上述代码中,scrollToTop函数将窗口滚动到(0,0)位置,即页面的顶部。

总之,gotopage方法是一种非常有用的Web开发技术,可以帮
助我们实现页面跳转和滚动等功能。

无论是在开发网站还是应用程序,都可以使用该方法来提高用户体验和页面交互性。

js方式的页面跳转

js方式的页面跳转

通过js或者html或者php等动态程序都可以方便的实现跳转,这里搜集了几种页面跳转的方式js方式的页面跳转1.window.location.href方式<script language="javascript" type="text/javascript">window.location.href="/";</script>2.window.navigate方式跳转<script language="javascript">window.navigate("top.jsp");</script>3.window.loction.replace方式实现页面跳转,注意跟第一种方式的区别<script language="javascript">window.location.replace("") ;</script>有3个jsp页面(1.jsp, 2.jsp, 3.jsp),进系统默认的是1.jsp ,当我进入2.jsp的时候,2.jsp 里面用window.location.replace("3.jsp");与用window.location.href ("3.jsp");从用户界面来看是没有什么区别的,但是当 3.jsp页面有一个"返回"按钮,调用window.history.go(-1); wondow.history.back();方法的时候,一点这个返回按钮就要返回2.jsp页面的话,区别就出来了,当用window.location.replace("3.jsp");连到 3.jsp页面的话,3.jsp页面中的调用window.history.go(-1);wondow.history.back();方法是不好用的,会返回到1.jsp 。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

1. Javascript 返回上一页 history.go(-1), 返回两个页面: history.go(-2);
2. history.back().
3. window.history.forward()返回下一页
4. window.history.go(返回第几页,也可以使用访问过的URL)
例:
<a href="javascript:history.go(-1);">向上一页</a>
response.Write("<script language=javascript>")
response.Write("if(!confirm('完成任务?')){history.back();}") response.Write("</script>")
response.Write("<script
language=javascript>history.go(-1);</script>")
<a href="javascript:history.go(-1);">向上一页</a>
页面跳转:onclick="window.location.href='list.aspx'"
P.S.
小技巧(JS引用JS):
<script type=text/javascript>
<!--
if (typeof SWFObject == "undefined") {
document.write('<scr' + 'ipt type="text/javascript"
src="/scripts/swfobject-1.5.js"></scr' + 'ipt>');}
//-->
</script>
Javascript刷新页面的几种方法:
1 history.go(0)
2 location.reload()
3 location=location
4 location.assign(location)
5 document.execCommand('Refresh')
6 window.navigate(location)
7 location.replace(location)
8 document.URL=location.href
自动刷新页面的方法:
1.页面自动刷新:把如下代码加入<head>区域中
<meta http-equiv="refresh" content="20">
其中20指每隔20秒刷新一次页面.
2.页面自动跳转:把如下代码加入<head>区域中
<meta http-equiv="refresh"content="20;url=">
其中20指隔20秒后跳转到页面
3.页面自动刷新js版
<script language="JavaScript">
function myrefresh()
{
window.location.reload();
}
setTimeout('myrefresh()',1000); //指定1秒刷新一次
</script>
如何输出刷新父窗口脚本语句
1. this.response.write("<script>opener.location.reload();</script>");
2. this.response.write("<script>opener.window.location.href = opener.window.location.href;</script>");
<A href="/">手持终端</A>
<A href="/">手持机</A>
3. Response.Write("<script
language=javascript>opener.window.navigate(''你要刷新的
页.asp'');</script>")
JS刷新框架的脚本语句
//如何刷新包含该框架的页面用
<script language=JavaScript>
parent.location.reload();
</script>
//子窗口刷新父窗口
<script language=JavaScript>
self.opener.location.reload();
</script>
( 或<a href="javascript:opener.location.reload()">刷新</a> )
//如何刷新另一个框架的页面用
<script language=JavaScript>
parent.另一FrameID.location.reload();
</script>
如果想关闭窗口时刷新或者想开窗时刷新的话,在<body>中调用以下语句即可。

<body onload="opener.location.reload()"> 开窗时刷新
<body onUnload="opener.location.reload()"> 关闭时刷新
<script language="javascript">
window.opener.document.location.reload()
</script>。

相关文档
最新文档