I have a php file which is been used to share posts of my users on Facebook and Twitter. If I click on the Twitter icon for example, I get a screen where the hyperlink to my site is automatically been written. This is good, but I like to remove the www. part of the url that is automatically shown on the Twitter screen. I guess this has something to do with location.host, so I googled, but I couldn’t find a proper answer to this problem.
Here is an example of my code:
function e(f,i,an)
{
with(document)
{
write('<div style="width:100%"><table id=m'+i+' style="visibility:hidden"><tr>');
write('<td id="vst' + i + '" style="white-space:nowrap"> </td>');
write('<td hr(this.childNodes[0])" title="share on facebook"><a href="javascript:od(\'http://www.facebook.com/sharer.php?u=' + location.host + '/e/'+ i +'\',900,400)" class=icon><img src="images/facebook.png" target="_blank"></a></td>');
write('<td hr(this.childNodes[0])" title="share on twitter"><a href="javascript:od(\'http://twitter.com/home?status=' + location.host + '/e/'+ i +' - %20read!\',800,600)" class=icon><img src="images/twitter.png" target="_blank"></a></td>');
write('<td class=ei><a name="cid'+i+'"></a><a href="e/'+i+'">( #'+i+' )</a></td>');
document.write('<td> </td>');
My second question would be this: how can I add a custom title on the Twitter screen: for example, my websitename without having to use location.host together with the title of the TOPICNAME that is being shared?
For your first… you could modify the host:
Edit: address concerns
Having been down-voted again, and seeing lots of up-votes on the first comment, I will attempt to address concern about subdomains besides
wwwthat containwww…Still steering clear of regex for this solution, mostly because generally it is harder to maintain regex, and there are a lot of developers who just don’t touch regex at all…
… or more succinctly …