I am working on a random quote machine and am trying to add a button that tweets the quote displayed on the screen. I can get it to work for basic quotes using encodeURI()
but some of my quotes have special characters like brackets, colons, and semi-colons.
I've tried escape()
, encodeURI()
, and encodeURIComponent()
, but none of these work with these characters. Here is what I have for the twitter button (content
is the variable that contains the quote I want to tweet). How can I tweet quotes with these special characters?
$("#twitter-share").click(function(){
window.open('https://twitter.com/intent/tweet?text="' + encodeURI(content) + '"', '_blank');