Last active
March 4, 2024 06:23
-
-
Save laomo/c160978924dcb52a45977230b0b2a3ba to your computer and use it in GitHub Desktop.
打开网页自动向指定号码发送短信
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- https://example.com/sms.html?phone=12306&content=999 --> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>发送短信</title> | |
</head> | |
<body> | |
<script> | |
function isAndroid() { | |
return navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Adr') > -1; | |
} | |
window.onload = function() { | |
// 获取 URL 参数 | |
const urlParams = new URLSearchParams(window.location.search); | |
// 获取手机号 | |
const phoneNum = urlParams.get('phone'); | |
// 获取短信内容 | |
const content = urlParams.get('content'); | |
// 跳转到短信页面 | |
if (isAndroid()) { | |
window.location.href = `sms:${phoneNum}?body=${content}`; | |
} else { | |
window.location.href = `sms:${phoneNum}&body=${content}`; | |
} | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment