This is how you can create a vcard on a button click
If you’re directing people to a page by QR code from a phone, it can be useful for them to be able to populate their contacts with your business info.
<p align=”center”><button style=”background-color:#C92159; color:white;text-transform: uppercase;” onclick=”generateVCard()”>Generate vCard</button>
</p>
<script>
function generateVCard() {
var vCardData = {
firstName: “Ian”,
lastName: “Phillips”,
organization: “Kuchi Solutions”,
email: “[email protected]”,
phone: “0781 805 5691”
};
var vCardString = “BEGIN:VCARD\n” +
“VERSION:3.0\n” +
“FN:” + vCardData.firstName + ” ” + vCardData.lastName + “\n” +
“ORG:” + vCardData.organization + “\n” +
“EMAIL:” + vCardData.email + “\n” +
“TEL:” + vCardData.phone + “\n” +
“END:VCARD”;
var blob = new Blob([vCardString], { type: “text/vcard;charset=utf-8” });
var url = window.URL.createObjectURL(blob);
var a = document.createElement(“a”);
a.href = url;
a.download = “contact.vcf”;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}
</script>