Can't get twitter button to open new window


This project is definitely challenging! Been muddling my way through it (apologies for repeating myself in the JavaScript, will fix that at some point). I am almost done with the functionality, but can’t get the twitter button to open a new window. Any pointers?


the problem was that the button had no link.

I have added the link to the button and configured via jQuery and it works ok :slight_smile:

You must remove this first


Button Update (see the new a tag):-

 <div id = "tweet">
     <button id="tweetbutton" type="button"><a id="tweetme">Tweet this quote!</a></button> 

Button Jquery:- this works by adding the href attribute to the buttons new a tag each time your new quote btutton is clicked. the target blank is the new window. the new jquery replaces the function and must go like so:–

place the new jquery directly under this line and before the }); so it sits inside your quotebutton function.

$('#authordiv').append('<p id="author"> - ' + authors[y] + '</p>');

New Jquery

//configure tweet button with quote and author info
$('#tweetme').attr('href', '' + '"' + quotes[y] + '"' + '  ~' + authors[y]);
$('#tweetme').attr('target', '_blank');

Hope this helps


You can update code as following :

<div id = "tweet">
<a target="_blank" title="" href="">
<button id="tweetbutton"  type="button">Tweet this quote!</button></a>

This will only help to open new window.

Hope this helps !!!