html页面点击按钮实现页面跳转功能(html 点击)
生活随笔
收集整理的這篇文章主要介紹了
html页面点击按钮实现页面跳转功能(html 点击)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
html頁面點擊按鈕實現頁面跳轉
方法1、在button標簽外嵌套一個a標簽,利用超鏈接進行跳轉;
<a target="_blank"> ?<button>進入baidu首頁</button> </a>
方法2、在button標簽中添加οnclick="window.location.href=‘頁面url’"代碼,使用onclick事件進行跳轉。
<button onclick="window.location. target="_blank"">進入baidu首頁</button>
html頁面自動跳轉方法
1.使用meta元素
<meta http-equiv="refresh" content="5;url=hello.html">
http-equiv=“refresh” 是刷新頁面,5秒后執行刷新操作,url是跳轉的目的頁面地址。
<meta http-equiv="refresh" content="5">
這行代碼的意思是只刷新,不跳轉。
2.使用script代碼
立即跳轉到hello.html頁面。
<script type="text/javascript"> ?? ?window.location.href = 'hello.html'; </script>
或者
<script language="javascript">
?? ?location.replace("http://www.baidu.com/");
</script>
5秒后跳轉到hello.html頁面。
<script type="text/javascript">
?? ?setTimeout("window.location.href = 'hello.html'", 5000);
</script>
3.判斷是否手機端
<script type="text/javascript">
var wapurl = window.location.pathname;?
if
?? ?(/Android|webOS|iPhone|iPod|BlackBerry|Windows CE|Windows Phone/i.test(navigator.userAgent))
{if
?? ?(window.location.href.toLowerCase().indexOf("?pc")<0)
{try
?? ?{window.location.href="/wap"+wapurl}
?? ?catch(e){}}
?? ?}
</script>
到此這篇關于html頁面點擊按鈕實現頁面跳轉的文章就介紹到這了,更多相關html點擊按鈕跳轉頁面內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關文章,希望大家以后多多支持腳本之家!
總結
以上是生活随笔為你收集整理的html页面点击按钮实现页面跳转功能(html 点击)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 小米手表Color获OTA升级:新增游泳
- 下一篇: 野菜苦菜怎么做好吃呢?