How to open a new window using the tweet button

I have many custom tweet buttons on my page that I dynamically generate using this PHP line 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 fine, however, it runs on the same tab and moves me from the page from which it was called. I would like to open the sharing dialog in a new window, but my Javascript background is limited to formal validation and a few Jquery Ajax calls, so I don't know how to do this. How can I open a dialog in a new window?

+7
source share
4 answers

Just use the Javascript function for your anbd anchor tag in this function using window.open (), passing the URL to open it in a new window. Hope it works

+1
source

it worked well

 <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;" 
+16
source

I ended up setting up the popitup function provided by this link: http://www.quirksmode.org/js/popup.html

+4
source

You just need to add "target = _blank" to your 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>"; 
+1
source

All Articles