Sharing link on WhatsApp from mobile website (not application) for Android
Just saw it on a website and seems to work on latest Android with latest chrome and whatsapp now too! Give the link a new shot!
<a href="whatsapp://send?text=The text to share!" data-action="share/whatsapp/share">Share via Whatsapp</a>
Rechecked it today (17th April 2015):
Works for me on iOS 8 (iPhone 6, latest versions) Android 5 (Nexus 5, latest versions).
It also works on Windows Phone.
Whatsapp sharing button with a countdown variable
The countdown_iam
variable is created within a function and only exists within that function. So when the other function (openWhatsApp
) tries to use the variable, it can't find it and the error occurs.
You want to access the countdown string from two different functions, so one option would be to create a new function that makes the countdown string and returns it. You can then call that function from both places. I've done that here:
<script>
function getCountdown() {
var countdownDate = new Date("Aug 20, 2022 12:00:00").getTime();
var now = new Date().getTime();
var distance = (countdownDate - now) / 1000;
if (distance < 0) {
return 'SURPRISE!!!';
} else {
var days = Math.floor(distance / (60 * 60 * 24));
var hours = Math.floor((distance % (60 * 60 * 24)) / (60 * 60));
var minutes = Math.floor((distance % (60 * 60)) / 60);
var seconds = Math.floor(distance % 60);
return days + "j " + hours + "h " + minutes + "m " + seconds + "s ";
}
}
function openWhatsApp() {
alert('whatsapp://send?text=' + getCountdown());
}
setInterval(function() {
document.getElementById("countdown").innerHTML = getCountdown();
}, 1000);
</script>
<h2>WhatsApp Sharing Link</h2>
<p id="countdown"></p>
<p><img src="img/whatsapp.png" height="50" size="50" onclick="openWhatsApp()"></p>
Related Topics
How to Get Foreach Loop Variable Outside of Loop
How to Run a PHP Script in the Background After a Form Is Submitted
How to Send Data Using Redirect With Laravel
Update Database After Select Option Change
Php Regex Find Text Between Custom Added HTML Tags
How to Set Variables in a Laravel Blade Template
Get All Hrefs from String But Then Replace Via Another Method
Send Attachments With PHP Mail()
The Get Method Is Not Supported for This Route. Supported Methods: Put. But I'M Using Put
Convert Svg Image to Png With PHP
How to See If a User Is Online in a Website With PHP and MySQL Driven Databases
Running a Python Script from PHP
Php: How to Detect If a Session Has Expired Automatically
Convert Accented Characters to Their Plain Ascii Equivalents