本文提供兩種方式,以實現(xiàn):
在html中,點擊按鍵,跳轉(zhuǎn)至另一html頁面,或跳轉(zhuǎn)至百度等網(wǎng)頁。
方法一:通過超鏈接標簽<a>實現(xiàn):
??????????????在button外添加父標簽,超鏈接<a>:
??????????????????????跳轉(zhuǎn)至百度:
<a >
<button>百度1</button>
</a>
???????????????????????跳轉(zhuǎn)至另一html頁面:(注意href后跟的路徑需要正確,對應(yīng)正確的另一html頁面)
<a href="page2.html">
<button>登錄1</button>
</a>
方法二:通過button設(shè)置onclick事件,在js中綁定事件函數(shù)實現(xiàn):
???????????????跳轉(zhuǎn)至百度:
<button onclick="toBaidu()">百度2</button>
<script>
function toBaidu(){
window.location.;
}
</script>
? ? ? ? ? ? ? ? 跳轉(zhuǎn)至另一html頁面:文章來源:http://www.zghlxwxcb.cn/news/detail-548044.html
<button onclick="login()">登錄2</button>
<script>
function login(){
window.location.href="page2.html";
}
</script>
通過以上兩種方法,均可實現(xiàn)跳轉(zhuǎn)。文章來源地址http://www.zghlxwxcb.cn/news/detail-548044.html
到了這里,關(guān)于html 點擊按鍵跳轉(zhuǎn)至百度/其他html頁面(原生js)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!