Opening a Tweet text window

var tweetQuote = function() { var twBody = document.getElementById("tweet-body").textContent; var twURL = "https://twitter.com/intent/tweet?text="; window.open(twURL + twBody); }; // End of tweeting quote document.getElementById("tweetbtn") .addEventListener("click", tweetQuote); /* HTML <div id="tweet-body"> I will tweet this phrase, nobody will stop me! </div> <button id="tweetbtn">Tweet it</button> */
Add a tweet button to open a pop-up ready to tweet a certain element's text.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.