Random Quote Machine - Tweet button issue

Random Quote Machine - Tweet button issue
0

#1

Hi All,

My Random Quote Machine works perfectly but the tweet button works only in Google Chrome and locally on my machine.
If I open the same code web page with Firefox Developer Edition or in Codepen, the tweet button does not work.

Your help would be highly appreciated.


#2

Two things that might help.

The $("#tweetbutton") should be $("#tweetButton") with a capital B to match your html id.

Your line :

$("a").attr("href", "https://www.twitter.com/intent/tweet?hashtags=randomQuoteMachine&text=") + encodeURIComponent(randomQuote + " - " + randomAuthor);

Should be written like this:

$("a").attr("href", "https://www.twitter.com/intent/tweet?hashtags=randomQuoteMachine&text=" + encodeURIComponent(randomQuote + " - " + randomAuthor));

The difference is the closing parenthesis needed to be moved to the end before the semi-colon.

Hope this helps a bit.


#3

Hi,

Thanks for your response, it actually helped for Codepen but only on Chrome. I am still having the same issue on Firefox. It seems there some support issue here :sweat_smile:


#4

To make it work in all browsers, you should nest the button within the anchor tag instead nesting the anchor tag within the button.


#5

Hi @RandellDawson :slightly_smiling_face:

That worked perfectly. Was this related to browser support?

Thanks a lot!!!


#6

In a way it is. But in general, it is the proper way to do it to avoid issues.