Skip to content

Instantly share code, notes, and snippets.

@MarcoDeJong
Created July 22, 2014 19:00
Show Gist options
  • Save MarcoDeJong/e8654579ccfeaf0b7e0c to your computer and use it in GitHub Desktop.
Save MarcoDeJong/e8654579ccfeaf0b7e0c to your computer and use it in GitHub Desktop.
Whatsapp share link (or button)
<html>
<head>
<meta name='viewport' content='width=device-width, user-scalable=yes'>
</head>
<body>
<h1>Whatsapp share link</h1>
<p>This will currently only work on an iPhone</p>
<script>
var iOS = /(iPhone)/g.test(navigator.userAgent);
if(iOS) {
var notice = document.createElement('p');
notice.appendChild(document.createTextNode('Hey, you are on an iPhone ;)'));
document.body.appendChild(notice);
}
</script>
<a href="javascript:window.location='whatsapp://send?text='+encodeURIComponent(location.href);">Share this page</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment