Reputation: 29514
i am having the link like
<a href="http://twitter.com/home/?status='.$markme_ddesc.'" onclick="OpenPopup(this.href); return false">Click Here to See Popup</a>
for bookmarking the article clicked to twitter .. The above one just add the articles message to twitter.. But i am trying to add my article link also to twitter,.. so i am using the location.href but its not working tat is its not showing me the articles site name..
THe below is the one i tried..
<a href="http://twitter.com/home/?status=\'+encodeURIComponent(location.href)+\'-'.$markme_ddesc.'" onclick="OpenPopup(this.href); return false">Click Here to See Popup</a>
Thanks i advance.. Help me to get out of this...
Upvotes: 0
Views: 638
Reputation: 8766
You can try this:
<a href="http://twitter.com/home/?status=" desc="<?php echo $markme_ddesc; ?>" onclick="OpenPopup(this.href,this.desc); return false">Click Here to See Popup</a>
<script>
function OpenPopup(href,desc){
var url = href + encodeURIComponent(location.href) + '-' + desc;
//show popup here...
}
</script>
Upvotes: 1
Reputation: 523724
It seems that you're using PHP, so you could use
'<a href="...' . urlencode(curPageURL()) . '-' . $markme_ddesc . '...'
where curPageURL
is a custom function to get the full URL. (Or use $_SERVER['REQUEST_URI']
if the domain is not needed.)
But if you really need to attach the URL from client side, you need to use Javascript.
<a id="xyz" href="http://twitter.com/home/?status=@PLACEHOLDER@-'.$markme_ddesc.'" … >
...
// onload:
var xyz = document.getElementById('xyz');
xyz.href = xyz.href.replace(/@PLACEHOLDER@/g, encodeURIComponent(location.href));
Of course this will fail if the client doesn't enable Javascript.
Upvotes: 2