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 可以是相对路径或绝对路径。

js中top.location.href、parent.location.href用法

js中top.location.href、parent.location.href用法

js中top.location.href、parent.location.href⽤法window.location.href、location.href是本页⾯跳转parent.location.href是上⼀层页⾯跳转top.location.href是最外层的页⾯跳转举例说明:window.location.href、location.href:例:代码如下复制代码window.location.href= 'wapsend1.asp?zimu=A&rev= ' + form1.rev.value ;parent.location.href:C页⾯跳转例:代码如下复制代码window.parent.parent.location.href=“你定义要跳转的页⾯”top.location.href:A页⾯跳转例:在form提交表单的时候有个属性可能对上⾯的(2)的情况有⽤target=_top代码如下复制代码<form name=loginForm action=Login.action method=post target=_top></form>例2代码如下复制代码echo <iframe width=0 height=0 frameborder=0 scrolling=auto src='登录论坛' onload='reurl()'></iframe>;echo <script> function reurl(){top.location.href='.$url.'}</script>;也可以直接在表单提交是的target加个即可<form>: form提交后D页⾯跳转<form target=_blank>: form提交后弹出新页⾯<form target=_parent>: form提交后C页⾯跳转。

js跳转新页面的几种方法

js跳转新页面的几种方法

js跳转新页面的几种方法在JavaScript中,有多种方法可以实现跳转到新页面。

下面是几种常见的方法:1. 使用location.href 方法:javascriptlocation.href = "这种方法是直接修改`location` 对象的`href` 属性,将其值设置为目标页面的URL。

当执行这行代码时,浏览器会立即跳转到新页面。

2. 使用location.assign 方法:javascriptlocation.assign("这个方法与`location.href` 方法类似,也是用于跳转到新页面。

它将目标页面的URL 作为参数,并将其赋值给`location` 对象的`href` 属性。

3. 使用location.replace 方法:javascriptlocation.replace("这种方法也可以用于跳转到新页面,但与前两种方法不同的是,它不会在浏览器的历史记录中生成新的记录。

也就是说,用户无法通过浏览器的“后退”按钮返回到前一个页面。

4. 使用window.open 方法:javascriptwindow.open("这是一种在新窗口或标签页中打开目标页面的方法。

当执行这行代码时,浏览器会弹出一个新的窗口或标签页,并在其中加载目标页面。

5. 使用form 提交:html<form id="myForm" action=" method="GET"><input type="submit" value="Go"></form><script>document.getElementById("myForm").submit();</script>这种方法不是直接使用JavaScript 来实现跳转,而是利用一个隐藏的表单,将其目标地址设置为目标页面的URL,并通过JavaScript 代码触发表单的提交动作,从而实现跳转到新页面。

js跳转页面的几种方法

js跳转页面的几种方法

js跳转页面的几种方法在JavaScript中,跳转页面是常见的操作之一,主要用于实现页面间的导航和重定向。

以下是一些常用的JavaScript跳转页面的方法:1. 使用window.location对象`window.location`对象是浏览器窗口中当前加载的文档的地址信息,我们可以通过修改它的属性或方法来实现页面跳转。

a) 使用window.location.href`window.location.href`属性用于获取或设置当前页面的URL。

要跳转到新的页面,我们可以直接给它赋值一个新的URL。

javascriptwindow.location.href = "这段代码将会使浏览器跳转到"b) 使用window.location.assign()`window.location.assign()`方法也可以用来加载新的URL。

使用方法如下:javascriptwindow.location.assign("这段代码的效果和上一段代码相同,也会使浏览器跳转到"2. 使用document.location对象`document.location`对象与`window.location`对象功能相同,也可以用来获取或设置当前页面的URL。

使用方法如下:javascriptdocument.location.href = "或者javascriptdocument.location.assign("这两段代码同样可以实现页面跳转。

3. 使用location.reload()方法`location.reload()`方法用于重新加载当前页面。

如果想强制从服务器重新加载(而不是从缓存中加载),可以传递一个true参数:javascriptlocation.reload(true);这种方法并不真正实现页面跳转,但有时候我们需要刷新页面以获取最新的数据或状态,这时就可以使用这个方法。

网页自动跳转HTML、PHP、.NET、JSP等代码大全

网页自动跳转HTML、PHP、.NET、JSP等代码大全
从搜索引擎优化的角度出发,一般不希望自动转向有延迟。不过,如果是用Meta Refresh标识进行转向,一定要注意把延迟时间设定成至少10秒以上。
“javascript”自动转向法
由于不能解析javascript,所以搜索引擎无法察觉(自动检测到)用javascript脚本进行的自动转向。javascript自动重定向脚本可以放在网页的任何位置上,如果要求立即跳转,则可以将其放入网页源码的<head>区内的最上面。用javascript实现跳转的范例如下:
<script>
t = -1; //计数器
setInterval("testTime()",1000); //启动1秒定时
function testTime() {
if(t<0) return; //计数器值小于0,表示尚未开始倒计时
if(t == 0) //计数器值为0,转向
location = "";
view.innerHTML = "<b>"+t+"</b>"; //显示倒计时
t--; //计数器递减
}
function offTime() {
if(event.srcElement.value != "点击开始") { //若不是倒计时开始
t = -1; //初始计数器
view.innerHTML = ""; //清空倒计时
Meta Refresh Tag自动转向法
由于搜索引擎能够读取HTML,而Meta tags也是HTML,所以对于这种自动转向法,搜索引擎能够自动检测出来。因而无论网站的转向出于什么目的,都很容易被搜索引擎视做对读者的误导而受到惩罚。不过,如果跳转延迟时间设置合适,搜索引擎就不会视之为作弊。

JS在一定时间内跳转页面及各种刷新页面的实现方法

JS在一定时间内跳转页面及各种刷新页面的实现方法

JS在⼀定时间内跳转页⾯及各种刷新页⾯的实现⽅法1.js 代码:<SCRIPT LANGUAGE="JavaScript">var time = 5; //时间,秒var timelong = 0;function diplaytime(){ //时间递减document.all.his.innerHTML = time -timelong ;timelong ++;}function redirect(){ //跳转页//history.back();window.location.href="Category-list";//指定要跳转到的⽬标页⾯}timer=setInterval('diplaytime()', 1000);//显⽰时间timer=setTimeout('redirect()',time * 1000); //跳转</SCRIPT>2.页⾯引⽤:<DIV ALIGN="CENTER" style="font-size:15;color:threeddarkshadow;" >如果你不执⾏任何操作,系统会在5秒后⾃动返回!</DIV><DIV ALIGN="CENTER" style="font-size:15;color:threeddarkshadow;" id="his">5秒钟后⾃动返回.....</DIV>javascript/js ⾃动刷新页⾯和页⾯跳转的实现⽅法1)<meta http-equiv="refresh"content="10;url=跳转的页⾯">10表⽰间隔10秒刷新⼀次2)<script language=''javascript''>window.location.reload(true);</script>如果是你要刷新某⼀个iframe就把window给换成frame的名字或ID号3)<script language=''javascript''>window.navigate("本页⾯url");</script>4>function abc(){window.location.href="/blog/window.location.href";setTimeout("abc()",10000);}刷新本页:Response.Write("<script language=javascript>window.location.href=window.location.href;</script>")刷新⽗页:Response.Write("<script language=javascript>opener.location.href=opener.location.href;</script>")转到指定页:Response.Write("<script language=javascript>window.location.href='yourpage.aspx';</script>")刷新页⾯实现⽅式总结(HTML,ASP,JS)'by aloxy定时刷新:1,<script>setTimeout("location.href='url'",2000)</script>说明:url是要刷新的页⾯URL地址2000是等待时间=2秒,2,<meta name="Refresh" content="n;url">说明:n is the number of seconds to wait before loading the specified URL.url is an absolute URL to be loaded.n,是等待的时间,以秒为单位url是要刷新的页⾯URL地址3,<%response.redirect url%>说明:⼀般⽤⼀个url参数或者表单传值判断是否发⽣某个操作,然后利⽤response.redirect刷新。

js跳转新页面的方法 -回复

js跳转新页面的方法 -回复

js跳转新页面的方法-回复JS跳转新页面的方法在网页开发中,我们经常会遇到需要跳转到新页面的情况。

无论是通过用户点击事件或者在JS中进行页面跳转,掌握正确的方法都是非常重要的。

本文将详细介绍JS跳转新页面的方法,并逐步回答相关问题。

让我们一起来学习吧。

一、通过window.location.href实现页面跳转最常用的方法是使用window.location.href来实现页面跳转。

它将把页面的URL重定向到新的URL,从而实现跳转。

下面是使用该方法的示例代码:javascriptwindow.location.href = '这行代码将会把当前页面的URL跳转到'1.1 如何在新页面中打开链接?要在新页面中打开链接,可以通过在window.location.href的值中添加'_blank'来实现。

下面是示例代码:javascriptwindow.location.href = ' + '_blank';这样就会在新的浏览器选项卡中打开链接。

1.2 如何在当前页面刷新?有时候我们需要在当前页面进行刷新,可以通过设置window.location.href为当前页面的URL来实现刷新。

比如:javascriptwindow.location.href = window.location.href;这样就会刷新当前页面。

二、通过window.open方法实现页面跳转除了使用window.location.href,我们还可以使用window.open方法来实现页面跳转。

下面是使用该方法的示例代码:javascriptwindow.open(' '_blank');这行代码将会在新的浏览器选项卡中打开'2.1 如何在当前页面打开链接?要在当前页面中打开链接,可以在window.open方法的第二个参数中传入'_self'。

[HTML]js实现页面跳转,页面A跳到另一个页面B.以及页面传值(中文)

[HTML]js实现页面跳转,页面A跳到另一个页面B.以及页面传值(中文)

[HTML]js实现页⾯跳转,页⾯A跳到另⼀个页⾯B.以及页⾯传值(中⽂)要实现从⼀个页⾯A跳到另⼀个页⾯B,js实现就在A的js代码加跳转代码JS跳转⼤概有以下⼏种⽅式:第⼀种:(跳转到b.html)<script language="javascript" type="text/javascript">window.location.href="b.html";</script>第⼆种:(返回上⼀页⾯)<script language="javascript">window.history.back(-1);</script>第三种:<script language="javascript">window.navigate("b.html");</script>第四种:<script language="JavaScript">self.location=’b.html’;</script>第五种:<script language="javascript">top.location=’b.html’;</script>页⾯传值:第⼀个页⾯:<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>⽆标题⽂档</title></head><SCRIPT LANGUAGE="JavaScript">function test(){var s = document.getElementById("txt");location.href="test2.html?"+"txt="+encodeURI(s.value);}</SCRIPT><body><input type="text" id="txt"></br><input type="button" value="TEST" onclick="test()"/></body></html>第⼆个页⾯:(test2.html)<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>⽆标题⽂档</title></head><body><script language="javascript" type="text/javascript">var loc = location.href;var n1 = loc.length;//地址的总长度var n2 = loc.indexOf("=");//取得=号的位置var id = decodeURI(loc.substr(n2+1, n1-n2));//从=号后⾯的内容alert(id);//document.write(id)</script></body></html>注:中⽂传输:可以在页⾯a⽤encodeURI 编码url 在b页⾯⽤decodeURI解码url。

JS跳转页面延迟2种方法

JS跳转页面延迟2种方法

JS跳转页⾯延迟2种⽅法⽅法1:复制代码代码如下:<SPAN style="FONT-SIZE: 12px"><script type="text/javascript"><!--function go(t,url){//t设置跳转时间:秒//url设置跳转⽹址document.write("<div id=text>本页将在<strong id='tt'></strong>后,跳转⾄:<span id='link'></span></div>"); document.getElementById("link").innerHTML="<a href="+url+">"+url+"</a>";$(t,url);}function $(t,url){ta = t-1;tb = t + "000";d = document.getElementById("tt");d.innerHTML=t;window.setInterval(function(){go_to(url);},1000);}function go_to(url){d.innerHTML=ta--;if(ta<0){document.write("正在跳转⾄:<a href="+url+">"+url+"</a>");location.href=url;}else{return;}}//--></script><script type="text/javascript">go(5, "/Login.aspx")</script> </SPAN>⽅法2:复制代码代码如下:window.setTimeout("window.location='index.shtml'",2000);//两秒后跳转新页⾯。

js跳转的几种方式

js跳转的几种方式

js跳转的几种方式在网页开发中,跳转是一个非常常见的需求,在实际开发中会遇到使用js进行跳转的情况。

常见的js跳转有以下几种方式:一、location.href跳转这段代码表示跳转到百度首页。

该方式将窗口当前的页面位置导向到一个新的指定的URL。

location.replace()方法与location.href()方法类似,但有一个区别,就是通过location.replace()方法跳转到新页面后,用户不能通过浏览器的“后退”按钮回到原来的页面。

代码如下:三、window.open跳转window.open()方法打开一个新窗口或标签页,并载入指定的URL地址。

代码如下:该方法可设置窗口的宽度、高度、位置、工具栏、状态栏等属性,也可以指定所打开的窗口或标签页的名称。

location.reload()方法可以重新载入当前文档。

如果该文档自上次请求以来已经被修改,它将被重新下载。

如果未被修改,浏览器将从缓存中检索文档。

代码如下:该方法可接收一个可选的参数,如果传递true,代表强制刷新,跳过缓存,如果传递false,则只是重载数据而不强制刷新。

五、assign跳转使用assign()方法也可以实现跳转功能。

代码如下:该方法类似于location.href属性,可以将窗体重定向到新的URL地址,只是它与location.href属性的区别在于,assign()方法是修改了浏览器的历史记录栈,而location.href属性是在浏览器历史记录栈中加入了一个新的记录。

location.protocol属性返回表示URL协议的字符串(如"http:"或"https:")。

通过修改该属性可以实现跳转。

代码如下:location.protocol="http";该方法是将网站的协议修改为http,也可以将协议修改为https等。

总结以上就是js实现跳转的几种方式啦。

js跳转页面与打开新窗口的方法

js跳转页面与打开新窗口的方法

js跳转页⾯与打开新窗⼝的⽅法1.超链接<a href="" title="脚本之家">Welcome</a>等效于js代码window.location.href=""; //在同当前窗⼝中打开窗⼝2.超链接<a href="" title="脚本之家" target="_blank">Welcome</a>等效于js代码window.open(""); //在另外新建窗⼝中打开窗⼝//详细介绍第⼀种:<script language="" type="text/">window.location.href="/login.?backurl="+window.location.href;</script>第⼆种:<script language="javascript">alert("返回");window.history.back(-1);</script>第三种:<script language="javascript">window.navigate("dollare.");</script>第四种:<script language="JavaScript">self.location='dollare.htm';</script>第五种:<script language="javascript">alert("⾮法访问!");top.location='dollare.html;</script>1.在原来的窗体中直接跳转⽤window.location.href="你所要跳转的页⾯";2、在新窗体中打开页⾯⽤:window.open('你所要跳转的页⾯');window.history.back(-1);返回上⼀页3、⼀些⽤法按钮式:<INPUT name="pclog" type="button" value="/" onClick="location.href='连接地址'">链接式:<a href="javascript:history.(-1)">返回上⼀页</a><a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上⼀页</a>直接跳转式:<script>window.location.href='连接地址';</script>开新窗⼝:<a href="/javascript:" onClick="window.open('','','height=500,width=611,scrollbars=yes,status =yes')">123</a> width=250,toolbar=no,scrollbars="+scroll+",menubar=no");//写成⼀⾏OpenWindow.document.write("<TITLE>dollare雄仔⼯作室</TITLE>")OpenWindow.document.write("<BODY BGCOLOR=#ffffff>")OpenWindow.document.write("<h1>Hello!</h1>")OpenWindow.document.write("New window opened!<br> is Good")OpenWindow.document.write("</BODY>")OpenWindow.document.write("</HTML>")OpenWindow.document.close()}</SCRIPT></head><body><a href="#" onclick="openwin()">打开⼀个窗⼝</a><input type="button" onclick="openwin()" value="打开窗⼝"></body></html> 看看 OpenWindow.document.write()⾥⾯的代码不就是标准的HTML吗?只要按照格式写更多的⾏即可。

网页跳转引用代码

网页跳转引用代码

网页跳转引用代码1、<script language="javascript" type="text/javascript">window.location="";</script>将以上代码直接插入到body内的任意地方即可实现网页跳转的功能,将上面红色的网址替换成你要跳转到的网址。

2、<meta http-equiv="refresh" content="3; url=">将以上代码插入到<head></head>内,将以上红色部分的网址换成你要跳转的网址即可,蓝色部分的数字3,表示的是3秒钟后自动跳转。

3、<iframe name="content_frame" marginwidth=0 marginheight=0 width=100%height=30 src="import.htm" frameborder=0></iframe>但你会发现还会有点问题,就是背景色不同,你只要在引入的文件import.htm中使用相同的背景色也可以,但如果你使用的是IE5.5的话,可以看看这篇关于透明色的文章如果想引入的文件过长时不出现滚动条的话在import.htm中的body中加入scroll=no4、<object style="border:0px" type="text/x-scriptlet" data="import.htm" width=100% height=30></object>5、<span id=showImport></span><IE:Download ID="oDownload" STYLE="behavior:url(#default#download)" /><script>function onDownloadDone(downDate){showImport.innerHTML=downDate}oDownload.startDownload('import.htm',onDownloadDone)</script>要包含两个文件:top.htm/end.htm可以这样写——————————————————————————————————包含TOP.HTM<span id=showImport1></span><IE:Download ID="oDownload1"STYLE="behavior:url(#default#download)"/><script>function onDownloadDone(downData){showImport1.innerHTML=downData}oDownload1.startDownload('top.htm',onDownloadDone)</script> ——————————————————————————————————包含END.HTM<span id=showImport2></span><IE:Download ID="oDownload2"STYLE="behavior:url(#default#download)"/><script>function onDownloadDone(downData){showImport2.innerHTML=downData}oDownload2.startDownload('top.htm',onDownloadDone)</script> ——————————————————————————————————6、<%@ include file=”top.jsp ”%><jsp:include page=”top.jsp ”flush=”true”/>具体用法区别文档末尾详细解说7、Asp中:<!--#include file="head.asp"-->include和iframe的区别:1、使用范围include 动态页面 asp aspxiframe 动态静态均可使用2、页面组成include是代码级组合,iframe是视图级组合.<!--#include file="*.htm"-->是把*.htm的代码原封不动地加到现在的文件里,<iframe></iframe>是把指向的页面执行后显示相应的位置.3、执行include 作为引用页的一部分,在本页执行iframe 独立引用页,单独执行方法:jsp中的include我们都知道在jsp中include有两种形式,分别是<%@ include file=””%><jsp:include page=””flush=”true”/>通常当应用程序中所有的页面的某些部分(例如标题、页脚和导航栏)都相同的时候,我们就可以考虑用include。

  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>。

相关文档
最新文档