-1

Dear stackoverflowers,

I am displaying the latest tweet on my website. However, when I have a tweet that contains a link, it opens the link the same window.

My best guess would be to add the target-value to the . But how can I do that? Is there a trick for the Twitter API. (Twitter API: https://dev.twitter.com/docs/api/1/get/statuses/user_timeline

How can I change, that it opens containing links of a tweet in a new window?

.

Here is the markup that displays the latest tweet:

<div id="twitter_update_list"></div>
    <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
    <script type="text/javascript" src="http://api.twitter.com/1/statuses/user_timeline.json?screen_name=USERNAME&include_rts=true&count=1&callback=twitterCallback2"></script>
  • Solution found with javaScript. Just by adding the target-value atrribute. $('#twitter_update_list a').attr('target', '_new'); – Dennis Schröder Jun 02 '13 at 13:56
  • Dennis, if my answer helped at all, could you 'tick' it as correct, else I'll delete... cheers. – Jimbo Jul 24 '13 at 10:02

1 Answers1

0

I'll add a direct answer to your solution with your own findings: $('#twitter_update_list a').attr('target', '_new'); simply so this has an answer there. Now for the more important stuff:

You have a significant issue with your code: You're using the version 1 API which is deprecated and will soon be removed completely. This means your code will just stop working. That's it.

Here is a recent post explaining what's going on, briefly: Twitter API: Url search for Username

The difference is, your question is client-side and I do my stuff server-side with PHP. You will need to perform authenticated requests in the future. There are many resources out there to help you do this.

Community
  • 1
  • 1
Jimbo
  • 25,790
  • 15
  • 86
  • 131