在前(qian)端開發中,我們經常需(xu)要使用JavaScript來實現頁面(mian)之間(jian)的跳轉。下(xia)面(mian)介紹(shao)了幾種常見的跳轉方(fang)法。
復制代碼<script language="javascript" type="text/javascript"> window.location.href = "jingxuan.do?backurl=" + window.location.href; </script>
復制代碼<script> window.location.href = '//blog.yoodb.com';</script>
復制代碼<script language="javascript"> alert("返回"); window.history.back(-1);</script>復制代碼<a href="javascript:history.go(-1)">返回上一步</a><a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上一步</a>復制代碼<input name="前端知音" type="button" value="前端知音" onClick="location.href='login.do'">
復制代碼<a href="javascript:" onClick="window.open('login.do','','height=500,width=611,scrollbars=yes,status=yes')">新窗口</a>復制代碼<head> <!--只刷新不跳轉 --> <meta http-equiv="refresh" content="5"> <!--定時跳轉 --> <meta http-equiv="refresh" content="5;url=index.html"> </head>
以(yi)上(shang)是幾種常見(jian)的(de)使用(yong)JavaScript進行頁面(mian)跳轉的(de)方(fang)(fang)法(fa)。根據具體需(xu)求,選(xuan)擇(ze)合(he)適的(de)方(fang)(fang)法(fa)來實現頁面(mian)跳轉功能。