html按鈕如何設置超鏈接?html按鈕超鏈接的4種完成方法
發表時間:2023-08-31 來源:明輝站整理相關軟件相關文章人氣:
[摘要]在html中,有時候為了好看與方便可能會需要設置按鈕超鏈接,那么html按鈕怎么設置超鏈接呢?接下來本篇文章我們就來看看html按鈕超鏈接的四種實現方法,有需要的朋友可以參考一下。html按鈕設置超鏈接的方法一:使用超鏈接與button結合的方法html按鈕超鏈接代碼如下:<!DOCTYPE...
在html中,有時候為了好看與方便可能會需要設置按鈕超鏈接,那么html按鈕怎么設置超鏈接呢?接下來本篇文章我們就來看看html按鈕超鏈接的四種實現方法,有需要的朋友可以參考一下。
html按鈕設置超鏈接的方法一:使用超鏈接與button結合的方法
html按鈕超鏈接代碼如下:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<a href="http://www.php.cn/">
<input type=button value="php中文網" >
</a>
</body>
</html>
html按鈕超鏈接效果如下:

說明:<a> 標簽的 href 屬性用于指定超鏈接目標的URL。
html按鈕設置超鏈接的方法二:使用鏈接和css樣式設置將超鏈接設置成按鈕的形狀
html按鈕超鏈接代碼如下:
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
a.button {
-webkit-appearance: button;
-moz-appearance: button;
appearance: button;
text-decoration: none;
color: initial;
}
</style>
</head>
<body>
<a href="http://www.php.cn" class="button">php中文網</a>
</body>
</html>
html按鈕設置超鏈接的方法三:使用 form表單來設置html按鈕超鏈接
html按鈕超鏈接代碼如下:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form method="get" action="http://www.php.cn/">
<button type="submit">php中文網</button>
</form>
</body>
</html>
html按鈕設置超鏈接的方法四:使用window.location.href方法
完整的寫法:
<a href="鏈接">
<input type=button onclick="window.location.href('連接')">
</a>
說明:
1、若直接在本頁跳轉到新的頁面,則用: <input type=button onclick="window.location.href('連接')">
2、如果需要打開一個新的頁面進行跳轉,則用: <input type=button onclick="window.open('連接')">
以上就是本篇文章的全部內容了,更多其他精彩的內容大家可以關注PHP中文網�。�!
以上就是html按鈕怎么設置超鏈接?html按鈕超鏈接的四種實現方法的詳細內容,更多請關注php中文網其它相關文章!
網站建設是一個廣義的術語,涵蓋了許多不同的技能和學科中所使用的生產和維護的網站。