Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pop up new window with tweet button

I have many custom tweet buttons on my page that I am dynamically generating using this line of PHP executed in a loop:

echo "<li><a href=\"https://twitter.com/share?text=Check%20out%20{$items[$i]['name']}%20at%20completeset.us/item/{$items[$i]['item_id']}&url=&via=cmpltst\"  class=\"twitter\">T</a></li>";

This works perfectly fine, however, this executes in the same tab and navigates me away from the page it was called from. I would like to open the share dialog in a new window, but my Javascript background is limited to form validation and a few Jquery Ajax calls, so I have no idea how to go about doing this. How could I pop up the dialog in a new window?

like image 612
jaimerump Avatar asked Jul 13 '12 15:07

jaimerump


People also ask

Where is the new Tweet button on Twitter?

Type your Tweet (up to 280 characters) into the compose box at the top of your Home timeline, or click the Tweet button in the navigation bar. You can include up to 4 photos, a GIF, or a video in your Tweet. Click the Tweet button to post the Tweet to your profile.

How do I add Twitter to my home page?

Navigate to https://publish.twitter.com/ in your browser. Use the dropdown to select what type of content you would like to use. Then, copy the HTML code that pops up. Paste that code in the appropriate area of your website's source code.


3 Answers

this worked me fine

<a target=_blank href=\"https://twitter.com/share?text=Check%20out%20{$items[$i]['name']}%20at%20completeset.us/item/{$items[$i]['item_id']}&url=&via=cmpltst\"  class=\"twitter\  onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;" >T</a>

add onclick as

 onclick="javascript:window.open(this.href, '', 'menubar=no,
             toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;"
like image 178
Arjun Avatar answered Oct 19 '22 15:10

Arjun


Just have an on click Javascript function for your anchor tag anbd in that function use window.open() by passing your URL toopen it in new window.hope this works

like image 45
Santosh Sidnal Avatar answered Oct 19 '22 14:10

Santosh Sidnal


You just need to add the "target=_blank" to your a href:

echo "<li><a target=_blank href=\"https://twitter.com/share?text=Check%20out%20{$items[$i]['name']}%20at%20completeset.us/item/{$items[$i]['item_id']}&url=&via=cmpltst\"  class=\"twitter\">T</a></li>";
like image 36
Developer Avatar answered Oct 19 '22 14:10

Developer