整合营销服务商

电脑端+手机端+微信端=数据同步管理

免费咨询热线:

HTML中button标签点击实现页面跳转的三种方法

法1:使用onclick事件

<input type="button" value="按钮"
onclick="javascrtpt:window.location.href='http://www.baidu.com/'" />

或者直接使用button标签

<button onclick="window.location.href = 'https://www.baidu.com/'">百度</button>

方法2:在button标签外套一个a标签

<a href="http://www.baidu.com/">
 <button>百度</button>
</a>

或使用

<a href="http://www.baidu.com/"><input type="button" value='百度'></a>

方法3:使用JavaScript函数

51rgb

网页自动跳转页面的代码在很多时候都非常的有用,下面的是两个简单的例子。仅供参考。

方案一,用<meta>里直接写刷新语句:

<html>

<head>

<meta http-equiv="Content-Language" content="zh-CN">

<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">

<meta http-equiv="refresh" content="5;url=http://www.51rgb.com">

<title>html网页自动跳转代码--西农大网站</title>

</head>

<body>

测试:html网页自动跳转代码<br/>

你可以在这里写下你想的一切东西!<br />

如:西北农林科技大学是一所985、211院校。<br />

</body></html>

方案二,用javascript脚本来跳转

<html><head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>正在进入西农大网站</title>

</head>

<body>

<form name=loading>

<p align=center> <font color="#0066ff" size="2">正在进入,请稍等</font><font color="#0066ff" size="2" face="Arial">...</font>

<input type=text name=chart size=46 style="font-family:Arial; font-weight:bolder; color:#0066ff; background-color:#fef4d9; padding:0px; border-style:none;">

<inputtype=text name=percent size=47 style="color:#0066ff; text-align:center; border-width:medium; border-style:none;">

<script>

var bar=0

var line="||"

var amount="||"

count

function count{

bar=bar+2

amount =amount + line

document.loading.chart.value=amount

document.loading.percent.value=bar+"%"

if (bar<99)

{setTimeout("count",100);}

else

{window.location =http://www.51rgb.com;}

}</script>

</p>

</form><p align="center">

测试:html网页自动跳转代码<br/>

你可以在这里写下你想的一切东西!<br />

如:西北农林科技大学是一所985、211院校。<br /><br />

如果您的浏览器不支持跳转,<astyle="text-decoration: none" href="http://www.mycodes.net

"><font color="#FF0000">请点这里</font></a>.</p>

</body>

</html>

↓↓↓

、锚点链接的概念

我们在浏览一个网页的时候,通常会遇到比较长的网页,一直向下拉滚动条一直向下,而在最底部的位置通常会有一个一键返回到顶部

或者返回到哪里的按钮,这个按钮就是利用的 锚点链接 功能。

二、锚点链接的语法

就两个值:第一个就是锚点下在哪里?第二个就是点在哪里?

<body>

<!-- 2、跳转的目标位置:点-->

<a id="test">这里是顶部</a>

<!-- 1、跳转的按钮:锚-->

<a href="#test">回到顶部</a>

</body>

三、锚点的用法实例

源代码:↓

备注:如果手机上看格式错乱,建议粘贴到电脑版编辑器里观看。