JS跳转页面参考代码大全

合集下载

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]九种⽹页弹窗代码【1、最基本的弹出窗⼝代码】其实代码⾮常简单:<SCRIPT LANGUAGE="javascript"><!--window.open ("page.html")--></SCRIPT>因为着是⼀段javascripts代码,所以它们应该放在<SCRIPT LANGUAGE="javascript">标签和</script>之间。

<!-- 和 -->是对⼀些版本低的浏览器起作⽤,在这些⽼浏览器中不会将标签中的代码作为⽂本显⽰出来。

要养成这个好习惯啊。

window.open (page.html) ⽤于控制弹出新的窗⼝page.html,如果page.html不与主窗⼝在同⼀路径下,前⾯应写明路径,绝对路径(http://)和相对路径(../)均可。

⽤单引号和双引号都可以,只是不要混⽤。

这⼀段代码可以加⼊HTML的任意位置,<head>和</head>之间可以,<body>间</body>也可以,越前越早执⾏,尤其是页⾯代码长,⼜想使页⾯早点弹出就尽量往前放。

【2、经过设置后的弹出窗⼝】下⾯再说⼀说弹出窗⼝的设置。

只要再往上⾯的代码中加⼀点东西就可以了。

我们来定制这个弹出的窗⼝的外观,尺⼨⼤⼩,弹出的位置以适应该页⾯的具体情况。

<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")file://写成⼀⾏--></SCRIPT>参数解释:<SCRIPT LANGUAGE="javascript"> js脚本开始;window.open 弹出新窗⼝的命令;page.html 弹出窗⼝的⽂件名;newwindow 弹出窗⼝的名字(不是⽂件名),⾮必须,可⽤空代替;height=100 窗⼝⾼度;width=400 窗⼝宽度;top=0 窗⼝距离屏幕上⽅的象素值;left=0 窗⼝距离屏幕左侧的象素值;toolbar=no 是否显⽰⼯具栏,yes为显⽰;menubar,scrollbars 表⽰菜单栏和滚动栏。

JS定时刷新页面及跳转页面的方法

JS定时刷新页面及跳转页面的方法

JS定时刷新页⾯及跳转页⾯的⽅法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.复制代码代码如下:<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刷新页⾯的⼏种⽅法:复制代码代码如下://1history.go(0)//2location.reload()//3location=location//4location.assign(location)//5document.execCommand('Refresh')//6window.navigate(location)//7location.replace(location)//8document.URL=location.href1.页⾯⾃动刷新:把如下代码加⼊<head>区域中<meta http-equiv="refresh" content="20">其中20指每隔20秒刷新⼀次页⾯.2.页⾯⾃动跳转:把如下代码加⼊<head>区域中<meta http-equiv="refresh" content="20;url=https://">其中20指隔20秒后跳转到https:///tools/files.shtml页⾯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>");//3.Response.Write("<script language=javascript>opener.window.navigate(''你要刷新的页.asp'');</script>")复制代码代码如下://如何刷新包含该框架的页⾯⽤<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>中调⽤以下语句即可。

页面跳转代码(大全)

页面跳转代码(大全)

网页跳转代码大全<一>三种网页跳转代码:如果你要在服务器端跳转,可以这样:Response.Redirect()Response.End(这个是的服务器代码“常用的”)如果你要在客户端跳转,可以这样(js跳转):<script language="javascript" type="text/javascript">window.location="http: //";;</script>如果你要让页面显示几秒钟之后跳转,可以在html代码的<head></head>部分加上这样的代码:<meta http-equiv="refresh" content="3; url=">(3秒钟后自动跳转到)以上三种是也比较常见的页面跳转<二>几段简单的网页跳转代码不隐藏转向之后的地址代码一:<html><body><form name=loading><SCRIDIVT>var bar=0var line="||"var amount="||"count()function count(){bar=bar+2amount =amount + linedocument.loading.chart.value=amountdocument.loading.divercent.value=bar+"%"if (bar<99){setTimeout("count()",100);}else{window.location = "将这里改成要转入的网址";}}</SCRIDIVT></form></body></html>不隐藏转向之后的地址代码二:<html><body><scridivt language="javascridivt"><!--function goToURL() { //v2.0for (var i=0; i< (goToURL.arguments.length - 1); i+=2) //with arg divairs eval(goToURL.arguments+".location=''"+goToURL.arguments[i+1]+"''"); document.returnvalue = false;}//--></scridivt><body bgcolor="#FFFFFF"></body></html>不隐藏转向之后的地址代码三:<html><SCRIDIVT LANGUAGE="javascridivt"><!-- Start Codevar ver = navigator.adivdivVersion;if (ver.indexOf("MSIE") != -1){window.location.href="将这里改成要转入的网址如百度(httdiv:)" }elsewindow.location.href="将这里改成要转入的网址如百度(httdiv:)" // End Code --></SCRIDIVT></html>不隐藏转向之后的地址代码四:<html><body><meta httdiv-equiv="refresh" content="0.1;url=将这里改成要转入的网址"></body></html>可隐藏转向之后的地址:<html><frameset framesdivacing="0" border="0" rows="0" frameborder="0"><frame name="main" src="将这里改成要转入的网址" scrolling="auto" noresize></frameset></html><三>网页跳转<meta httdiv-equiv="refresh" content="3;rul=跳转的网页">此代码可以让网页在一定的时间内,跳转到另外一个网页上,其中content=" 为跳转前停暂的秒数,rul= 为跳转的网址<meta httdiv-equiv="refresh" content="3;rul=跳转的网页">此代码可以让网页在一定的时间内,跳转到另外一个网页上,其中content=" 为跳转前停暂的秒数,rul= 为跳转的网址===================================================================<html><head><title>网页跳转</title><meta httdiv-equiv="refresh" content="0;url=/"></head><body></body></html>===================================================================1,页面自动刷新:把如下代码加入<head>区域中<meta httdiv-equiv="refresh" content="20">,其中20指每隔20秒刷新一次页面.2,页面自动跳转:把如下代码加入<head>区域中<meta httdiv-equiv="refresh" content="10;url=h /">,其中10指隔10秒后跳转到/页面。

js实现网页跳转代码

js实现网页跳转代码

对于<a href="javascript:jump(“”)>的详细讲解一. 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>二.javascript:指的是伪协议,是指用url的形式调用javascript这句话相当于调用了javascript方法jump(“”);三.另外摘自网友的描述:关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法"window.location.href"、"location.href"是本页面跳转"parent.location.href"是上一层页面跳转"top.location.href"是最外层的页面跳转举例说明:如果A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js这样写"window.location.href"、"location.href":D页面跳转"parent.location.href":C页面跳转"top.location.href":A页面跳转如果D页面中有form的话,<form>: form提交后D页面跳转<form target="_blank">: form提交后弹出新页面<form target="_parent">: form提交后C页面跳转<form target="_top"> : form提交后A页面跳转关于页面刷新,D 页面中这样写:"parent.location.reload();": C页面刷新(当然,也可以使用子窗口的opener 对象来获得父窗口的对象:window.opener.document.location.reload(); )"top.location.reload();": A页面刷新。

js跳转的方法 -回复

js跳转的方法 -回复

js跳转的方法-回复JS 跳转的方法在网页开发中,经常需要实现页面之间的跳转。

JavaScript(简称JS)是一种强大的脚本语言,可以用来处理页面跳转的功能。

本文将详细介绍JS 中实现跳转的方法。

一、使用window.location.href 进行跳转最常见的跳转方法是使用window.location.href 属性。

该属性表示当前页面的URL 地址,通过修改该属性的值,可以实现页面的跳转。

要进行页面跳转,只需在JS 中使用以下代码:javascriptwindow.location.href = "目标页面的URL";其中,目标页面的URL 是指你想要跳转到的页面的地址。

可以是相对路径,也可以是绝对路径。

比如,如果你希望跳转到当前域名下的"target.html"页面,可以这样写:javascriptwindow.location.href = "target.html";如果希望跳转到其他域名下的页面,可以写成绝对路径的形式,如:javascriptwindow.location.href = "如果你想在当前页面中打开一个新的标签页并显示目标页面,可以使用以下代码:javascriptwindow.open("目标页面的URL");这样一来,新的标签页将会打开,并加载目标页面的内容。

二、使用location.replace 进行跳转除了使用window.location.href,还可以使用location.replace 方法来实现页面的跳转。

location.replace 方法的作用是,在跳转之后浏览器将不会保留当前页面的历史记录。

这意味着用户无法通过点击浏览器后退按钮返回到该页面。

使用location.replace 进行页面跳转的代码如下所示:javascriptlocation.replace("目标页面的URL");同样,目标页面的URL 可以是相对路径或绝对路径。

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

JS跳转页面参考代码
第一种:
<script language="javascript" type="text/javascript"> window.location.href="login.jsp?backurl="+window.location.href; </script>
第二种:
<script language="javascript">
alert("返回");
window.history.back(-1);
</script>
第三种:
<script language="javascript">
window.navigate("top.jsp");
</script>
第四种:
<script language="JavaScript">
self.location=’top.htm’;
</script>
第五种:
<script language="javascript">
alert("非法访问!");
top.location=’xx.jsp’;
</script>
=====javascript中弹出选择框跳转到其他页面=====
<script language="javascript">
<!--
function logout()...{
if (confirm("你确定要注销身份吗?是-选择确定,否-选择取消"))...{ window.location.href="logout.asp?act=logout"
}
}
-->
</script>
=====javascript中弹出提示框跳转到其他页面=====
<script language="javascript">
<!--
function logout()...{
alert("你确定要注销身份吗?");
window.location.href="logout.asp?act=logout"
}
-->
</script>
=================================
按钮式:
<INPUT name="pclog" type="button" value="GO"
onClick="location.href='/'">
链接式:
<a href="javascript:history.go(-1)">返回上一步</a>
<a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上一步</a>
直接跳转式:
<script>window.location.href='/';</script>
开新窗口:
<a href="javascript:"
onClick="window.open(/','','height=500,width=611,scrollbar s=yes,status=yes')">杭州威士顿网络科技有限公司</a>。

相关文档
最新文档