一键切换,随机拨打双号码
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>随机拨打电话</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
.container {
text-align: center;
}
.call-button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<h1>随机拨打电话</h1>
<button class="call-button" onclick="randomCall()">点击拨打电话</button>
</div>
<script>
function randomCall() {
const phoneNumbers = ["1234567890", "0987654321"]; // 定义两个电话号码
const randomIndex = Math.floor(Math.random() * phoneNumbers.length); // 随机选择一个索引
const selectedNumber = phoneNumbers[randomIndex]; // 获取随机选择的电话号码
window.location.href = 'tel:' + selectedNumber; // 调用拨号功能
}
</script>
</body>
</html>
发表评论