html5 web 按鈕跳轉(zhuǎn)方法(及其相關(guān))
方法一
<a href="javascript:" οnclick="history.go(-2); ">返回前兩頁(yè)</a>
方法二
<a href="javascript:" οnclick="self.location=document.referrer;">返回上一頁(yè)并刷新</a>
方法三
$(".btn").click(function(){
window.history.back();
});
//或者直接a標(biāo)簽添加
<a class="" href="javascript:history.go(-1)">返回</a>
1.點(diǎn)擊一個(gè)按鈕跳轉(zhuǎn)到另一個(gè)頁(yè)面 (網(wǎng)址) 兩種寫法:
<button οnclick="{location.href='location.html'}">獲取現(xiàn)在的位置</button>
<input type="button" value="go" οnclick="location.>
2.如果想彈出一個(gè)確認(rèn)框之后再跳轉(zhuǎn)
直接加代碼 if(confirm('確定跳轉(zhuǎn)?'))
<button οnclick="{ if(confirm('確定跳轉(zhuǎn)?'))location.href='body/location.html'}">位置</button>
<input type="button" value="go" οnclick="if(confirm('確定跳轉(zhuǎn)?')){location.href='
http://www.aseoe.com'}">
3.打開網(wǎng)頁(yè)時(shí)自動(dòng)觸發(fā)按鈕的單擊事件
// 在<body>里加一個(gè)οnlοad="abc()"的屬性就行了
<head>
<script type="text/javascript">
function abc(){
alert("onload");
}
</script>
</head>
<body onload="abc()">
</body>
-
asp跳轉(zhuǎn)
如果是在ASP.net中,雙擊按鈕,就可以進(jìn)入后臺(tái)頁(yè)面,然在在后臺(tái)頁(yè)面寫跳轉(zhuǎn)代碼 Response.Redirect("你想要跳轉(zhuǎn)的網(wǎng)頁(yè)");
如果在html中,可以寫一個(gè)form,指定你要跳轉(zhuǎn)到的頁(yè)面,當(dāng)然這個(gè)按鈕要這個(gè)form里面
例如:<form action="你要跳到的地址" method="post" > </form>
-
button 與 submit 的不同
type=button 就單純是按鈕功能
type=submit 是發(fā)送表單
但是對(duì)于從事WEB UI的人應(yīng)該要注意到,使用submit來(lái)提高頁(yè)面易用性:
使用submit后,頁(yè)面支持鍵盤enter鍵操作,而很多WEB軟件設(shè)計(jì)師,可能沒(méi)有注意到submit統(tǒng)一.
用button后往往頁(yè)面不支持enter鍵了。所以需要支持enter鍵,必須要設(shè)置個(gè)submit,默認(rèn)enter鍵對(duì)頁(yè)面第一個(gè)submit進(jìn)行操作。
<input type="submit" name="b1" value="提交" onClick="bt_submit_onclick()">
// 執(zhí)行完onClick,轉(zhuǎn)到action??梢宰詣?dòng)提交不需要onClick。onclick這里可以不要。
<input type="button" name="b1" value="提交" onClick="bt_submit_onclick()">
// 執(zhí)行完onClick,跳轉(zhuǎn)文件在 js文件里控制。提交需要onClick。
//比如:
οnclick="form1.action='a.jsp';form1.submit();" //這樣就實(shí)現(xiàn)了submit的功能了。
<form name="form1" method="post" action="http://www.meijus.com">
<input type="button" name="Button" value="Button" onClick="submit()"> </form>
<input type="button" name="Button" value="Button" onClick="javascript:windows.location.href="你的url"">
- js實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)的幾種方式:
第一種:
<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("非法訪問(wèn)!");
top.location='xx.jsp';
</script>文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-757273.html
<input type="button" name="btn" value="跳轉(zhuǎn)" οnclick="javascript:location.href='index.php'">
<input type="button" name="btn" value="返回" οnclick="javascript:history.back(-1)">文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-757273.html
到了這里,關(guān)于html5 web 按鈕跳轉(zhuǎn)方法(及其相關(guān))的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!