bcv2010
asked on
call javascript inside javascript var
I have the following script and want modifiy it so that the first script is only called when the tweeter onclick function fired.....I do not want to run the first script onload, just want to run it when onclick on tweeter button.. Is this possible ?
<script type="text/javascript" charset="utf-8" src="http://bit.ly/javascript-api.js?version=latest&login=tweettrackjs&apiKey=R_7e9987b2fd13d7e4e881f9cbb168f523"></script>
<script type='text/javascript'>
//<!--
var TweetAndTrack = {
open: function(targ, url, msg) {
var callback_name = url.replace(/\W/g, '');
BitlyCB[callback_name] = function(data) {
var result = TweetAndTrack.popResult(da ta);
var tweet_url = "http://twitter.com/home?status=" + encodeURIComponent( (msg ? msg + " " : '')+ result.shortUrl);
document.location.href=twe et_url
};
BitlyClient.call('shorten' , {'longUrl': url, 'history': '1'}, 'BitlyCB.' + callback_name);
return false;
},
popResult: function(data) {
// Results are keyed by longUrl, so we need to grab the first one.
for (var r in data.results) {
return data.results[r];
}
}
}
//-->
</script>
<div id="social_wrapper">
<div id="socialicons" class='share'>
<a href='<?php echo $stumble ?>' title='Share with Stumbleupon' target="_blank" rel="nofollow" class="stumble">
<!--img src='/images/modules/socia lnetwork/s tumbleupon .gif' width='16px' height='16px' alt='Sumble Upon' /-->
</a>
<a href='<?php echo $digg ?>' title='Share with Digg' target="_blank" rel="nofollow" class="digg">
<!--img src='/images/modules/socia lnetwork/d igg.gif' width='16px' height='16px' alt='Digg' /-->
</a>
<a href='<?php echo $facebook ?>' title='Share with Facebook' target="_blank" rel="nofollow" class="facebook">
<!--img src='/images/modules/socia lnetwork/f acebook.gi f' width='16px' height='16px' alt='Facebook' /-->
</a>
<a href="<?php echo $twitter ?>" onclick="return TweetAndTrack.open(this, '<?php echo JURI::current() ?>','I\'m currently loving this page on Blue Chip Vacations');" class="twitter">
<!--img src='/images/modules/socia lnetwork/t witter.gif ' width='16px' height='16px' alt='Twitter' /-->
</a>
<a href="<?php echo $email ?>" onclick="window.open(this. href,'win2 ','width=4 00,height= 350,menuba r=yes,resi zable=yes' ); return false;" class="email">
<!--img src='/images/modules/socia lnetwork/e mail.png' width='16px' height='16px' alt='Email' /-->
</a>
</div>
</div>
</div>
<script type="text/javascript" charset="utf-8" src="http://bit.ly/javascript-api.js?version=latest&login=tweettrackjs&apiKey=R_7e9987b2fd13d7e4e881f9cbb168f523"></script>
<script type='text/javascript'>
//<!--
var TweetAndTrack = {
open: function(targ, url, msg) {
var callback_name = url.replace(/\W/g, '');
BitlyCB[callback_name] = function(data) {
var result = TweetAndTrack.popResult(da
var tweet_url = "http://twitter.com/home?status=" + encodeURIComponent( (msg ? msg + " " : '')+ result.shortUrl);
document.location.href=twe
};
BitlyClient.call('shorten'
return false;
},
popResult: function(data) {
// Results are keyed by longUrl, so we need to grab the first one.
for (var r in data.results) {
return data.results[r];
}
}
}
//-->
</script>
<div id="social_wrapper">
<div id="socialicons" class='share'>
<a href='<?php echo $stumble ?>' title='Share with Stumbleupon' target="_blank" rel="nofollow" class="stumble">
<!--img src='/images/modules/socia
</a>
<a href='<?php echo $digg ?>' title='Share with Digg' target="_blank" rel="nofollow" class="digg">
<!--img src='/images/modules/socia
</a>
<a href='<?php echo $facebook ?>' title='Share with Facebook' target="_blank" rel="nofollow" class="facebook">
<!--img src='/images/modules/socia
</a>
<a href="<?php echo $twitter ?>" onclick="return TweetAndTrack.open(this, '<?php echo JURI::current() ?>','I\'m currently loving this page on Blue Chip Vacations');" class="twitter">
<!--img src='/images/modules/socia
</a>
<a href="<?php echo $email ?>" onclick="window.open(this.
<!--img src='/images/modules/socia
</a>
</div>
</div>
</div>
ASKER
Not sure what the code is about but I want the following code NOT to appear on page load, and want it appear when onclick
<script type="text/javascript" charset="utf-8" src="http://bit.ly/javascript-api.js?version=latest&login=tweettrackjs&apiKey=R_7e9987b2fd13d7e4e881f9cbb168f523"></script>
<script type="text/javascript" charset="utf-8" src="http://bit.ly/javascript-api.js?version=latest&login=tweettrackjs&apiKey=R_7e9987b2fd13d7e4e881f9cbb168f523"></script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
what about the closing script ?
the </script>
the </script>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok i will test it and let you know...
var TweetAndTrack = null;
function TandA() {
TweetAndTrack = {
And :
< a href="< ?php echo $twitter ? >" onclick="TandA();return TweetAndTrack.open(this, '< ?php echo JURI::current() ? >','I\'m currently loving this page on Blue Chip Vacations');" class="twitter" >
Open in new window