-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathredirect-page.html
42 lines (34 loc) · 1.4 KB
/
redirect-page.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html>
<head>
<title>Redirecionamento para o WhatsApp</title>
</head>
<body>
<script>
// Função para obter parâmetros da URL
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[?&]" + name + "=([^&#]*)");
var results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
// Obter os parâmetros da URL
var phone = getParameterByName("phone");
var text = getParameterByName("text");
// Verificar se os parâmetros estão vazios
if (phone !== "" && text !== "") {
// Aguardar 3 segundos (3000 milissegundos)
setTimeout(function() {
// Redirecionar para a página do WhatsApp com os parâmetros
var url = "https://api.whatsapp.com/send?phone=" + phone + "&text=" + text;
window.location.href = url;
}, 3000);
} else {
// Caso os parâmetros estejam vazios, você pode realizar outra ação aqui, se necessário.
console.log("Parâmetros ausentes. Nenhum redirecionamento realizado.");
}
</script>
<p>carregando...</p>
<!-- insira seu pixel de monitoramento aqui e saberá quando alguém clicou no whatsapp -->
</body>
</html>