js幾種跳轉

按鈕式:

鏈接式:<a href="javascript:history.go(-1)">返回上一步</a>
<a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上一步</a>

直接跳轉式:
<script>window.location.href='http://www.ddhbb.com';</script>

開新窗口:
<a href="javascript:" onClick="window.open('http://www.ddhbb.com/blog /guestbook.asp','','height=500,width=611,scrollbars=yes,status=yes')"& gt;布丁足跡</a>

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>


補充:
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頁面刷新


href的跳轉:
window.location.href("轉頁路徑");
document.location.href("轉業路徑");

action的跳轉:
『document.form1.action="action跳轉路徑";
document.form1.submit();』

直接調用form標籤中的action
document.form1.submit();

//調用跳轉方法
<a href="javascript: 方法"></a>

//調用驗證方法
<a href="javascript:return 方法" ></a>




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章