I want to create a share button to put on other sites like facebook or twitter and for that I need when I click the button it saves the url and sends it to my email, how do I do it?
I want to create a share button to put on other sites like facebook or twitter and for that I need when I click the button it saves the url and sends it to my email, how do I do it?
With this you can get the url
var url = window.location.href.toString();
Here is a simple example so that when the user clicks the button, open a window with the url. Possible to be shared (Ctrl + C)!
var copyBtn = document.getElementById('copyBtn');
copyBtn.addEventListener('click', function(event) {
/*Pega url*/
var url = window.location.href.toString();
/*seta para que a mesma possa ser compartilhada*/
window.prompt("Pressione: Ctrl+C, para compartilhar a url", url);
});
Button html
<button id="copyBtn">Salvar URL!</button>