/    Sign up×
Community /Pin to ProfileBookmark

Javascript and Twitter

Hello everyone,

I am trying to change a div content on the fly when buttons are clicked. I use a javascript function for that. It is fine as long as the div content is just text, images and regular html.

One button, however, is supposed to show someone’s twitter updates using the code harvested on twitter.com. I tried to put the twitter widget javascript code inside of a variable but it’s not working. Is it at all possible to include <script></script> tags in side javascript code?

Here is my javascript function:

function ReplaceContentInContainer(id,content) {
var container = document.getElementById(id);
container.innerHTML = content;
}

Here is what goes on the button:

<a href=”javascript:ReplaceContentInContainer(‘content’, twtr_updates)”><img src=”button.jpg” /></a>
[I]the div content is stocked in the ‘twtr_updates’ variable.[/I]

Now here is the Twitter widget code:

<script src=”http://widgets.twimg.com/j/2/widget.js”></script>
<script>
new TWTR.Widget({
version: 2,
type: ‘profile’,
rpp: 4,
interval: 6000,
width: 250,
height: 300,
theme: {
shell: {
background: ‘#333333’,
color: ‘#ffffff’
},
tweets: {
background: ‘#000000’,
color: ‘#ffffff’,
links: ‘#4aed05’
}
},
features: {
scrollbar: false,
loop: false,
live: false,
hashtags: true,
timestamp: true,
avatars: false,
behavior: ‘all’
}
}).render().setUser(‘InnotechNutri’).start();
</script>

Thank you in advance.

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @EricZed spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...