您的位置:首页 > 技术中心 > 前端框架 >

html按钮怎么设置超链接?html按钮超链接的四种实现方法

时间:2022-02-11 16:17

在html中,有时候为了好看与方便可能会需要设置按钮超链接,那么html按钮怎么设置超链接呢?接下来本篇文章我们就来看看html按钮超链接的四种实现方法,有需要的朋友可以参考一下。

html按钮设置超链接的方法一:使用超链接与button结合的方法

html按钮超链代码如下:

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<a href="http://www.gxlsystem.com/">
<input type=button value="gxlsystem.com" >
</a>
</body>
</html>

html按钮超链接效果如下:

2345截图20181009115410.png

说明:<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.gxlsystem.com" class="button">gxlsystem.com</a>
</body>
</html>

html按钮设置超链接的方法三:使用 form表单来设置html按钮超链接

html按钮超链接代码如下:

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<form method="get" action="http://www.gxlsystem.com/">
    <button type="submit">gxlsystem.com</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按钮超链接的四种实现方法的详细内容,更多请关注gxlsystem.com其它相关文章!

本类排行

今日推荐

热门手游