html点击按钮拨打电话
使用按钮
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>按钮拨打电话</title>
<style>
.call-button {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
.call-button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<h1>点击按钮拨打电话</h1>
<button class="call-button" onclick="makeCall()">拨打电话</button>
<script>
function makeCall() {
// 替换为你需要拨打的电话号码
const phoneNumber = "+861234567890";
window.location.href = `tel:${phoneNumber}`;
}
</script>
</body>
</html>使用a标签
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>拨打电话示例</title>
<style>
.call-button {
display: inline-block;
padding: 10px 20px;
background-color: #4CAF50;
color: white;
text-decoration: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
.call-button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<h1>点击按钮拨打电话</h1>
<a href="tel:+861234567890" class="call-button">拨打电话</a>
</body>
</html>