afridy
January 28, 2010, 5:46pm
1
folks
<a name="fb_share" type="icon_link" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
now i want to format the above url in the href like this
http://www.facebook.com/sharer.php?u=<url to share>
now, url to share is retrived by calling GetID() js function.
now how do i put function name with in the html
i put like this but did not work
href="http://www.facebook.com/sharer.php?u=GetID()"
pls help.
function () {
//do something
//do something
}
afridy
January 28, 2010, 7:38pm
3
nop blake anthoney,
my question seems not clear right.
assume this is my simple js function
<script language="JavaScript">
function getShortURL() {
var getShortURLText="http://www.someurl.com";
return getShortURLText;
}
</script>
assume above function is impliment like this
<a href=”getShortURL()”>post to facebook</a>
is this correct? it dont work for me :x
<a href="#" onclick="this.href=getShortURL()">post to facebok</a>
afridy
January 28, 2010, 8:13pm
5
hai AutisticCuckoo
that worked charm.
now my problem is this
from here i grab the code for a custom url
<a name=“fb_share” type=“icon_link” href=“http://www.facebook.com/sharer.php ”>Share</a><script src=“http://static.ak.fbcdn.net/connect.php/js/FB.Share ” type=“text/javascript”></script>
this require a url encording
http://www.facebook.com/sharer.php[B]?u=<Url to share>&t=<Title of content>[/B]
now my question is
if i did like this, it will not work
<script language=“JavaScript”>
function getShortURL() {
var getShortURLText=document.getElementById(“shorten-url-div”).innerHTML; //this returns the url which i wannt to share on fb.
getShortURLText=“http://www.facebook.com/sharer.php?u= ” + getShortURLText; // formatting my url to fb style
return getShortURLText;
}
</script>
and calling this function below
<a name=“fb_share” type=“icon_link” href=“#” onclick=“this.href=getShortURL()”>Share</a><script src=“http://static.ak.fbcdn.net/connect.php/js/FB.Share ” type=“text/javascript”></script>
what is the problem?
afridy
January 28, 2010, 8:30pm
6
folks, it seem i messed up with fb code. just tell me the bolded part is correct?
<a name=“fb_share” type=“button_count” share_url=“getShortURL()” href=“http://www.facebook.com/sharer.php ”>Share</a><script src=“http://static.ak.fbcdn.net/connect.php/js/FB.Share ” type=“text/javascript”></script>
share_url isn’t a valid link attribute, you’ll be wanting the onclick attribute instead.
afridy
January 29, 2010, 9:26am
8
hai pmw57,
not its part of that facebook share code only for the custom url
edited : if you put a url in to the share_url attribute insted of my js function, sharing works clearn.
i tried this and still not working
<a name=“fb_share” type=“button_count” href=“#” onclick=“this.href=getShortURL()”>Share</a><script src=“http://static.ak.fbcdn.net/connect.php/js/FB.Share ” type=“text/javascript”></script>
afridy
January 29, 2010, 9:51am
9
ok friends. i manage to solve this post to facebook with following code.
<a href="#" onclick="this.href=getShortURL()">post to facebok</a>
Thank you all and specially AutisticCuckoo for this.href