Facebook and Twitter share via iframe - javascript

I want to share referral url from my site via Twitter/Facebook share buttons. I have customized share buttons.
I am able to share referral url on these two sites but because target=_blank, facebook's Share Link and Twitter's Tweet page appears on a new tab.
I want then in an iFrame so that user won't leave my website while sharing referral links.
Facebook Share Code
<a title="send to Facebook"
href="http://www.facebook.com/sharer.php?s=100&p[title]=YOUR_TITLE&p[summary]=YOUR_SUMMARY&p[url]=YOUR_URL&p[images][0]=YOUR_IMAGE_TO_SHARE_OBJECT"
target="_blank">
<span>
Twitter Share Code
<a href="#" id="shareWithTwitter" onclick="shareWithTwitter()">
<img class="social-share" src="<?php echo site_url('img/twitter.png'); ?>"/>
</a>
function shareWithTwitter()
{
var url = 'https://twitter.com/home?status=Join Fashion on '+$('#referal-URL').val();
$('#shareWithTwitter').attr('href',url);
}

All you have to do is adding a name attribute to the iframe and target your link to it.
<iframe name="iframeName" style="iframe style"></iframe>
link
open link in iframe

Related

Addthis: Display total shares

I would like to get the AddThis widget to display the total number of shares of an URL on Facebook, Twitter and Google+. Here comes my code:
<script src="http://s7.addthis.com/js/250/addthis_widget.js"></script>
<div addthis:url="http://de.wikipedia.org/wiki/JavaScript" addthis:title="Wikipedia JavaScript page">
<a class="addthis_button_facebook"></a>
<a class="addthis_button_twitter"></a>
<a class="addthis_button_google_plusone"></a>
<a class="addthis_button_email"></a>
</div>
JSFIDDLE: http://jsfiddle.net/ez8ya0ov/
How do I achieve that the total count of shares on facebook, twitter and google+ get displayed in a bubble on the right side? I do NOT want the individual numbers of each social media service get displayed (in this example I want to get rid of the bubble with "7" next to the google+ icon). Anyone has an idea how to achieve that?

Tweet button shows incorrect of tweets

On a page I have a Tweet button, like this:
Tweet
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
The problem is that in the bubble with counts of tweets is the value 2197, which is incorrect.
How to put there the correct value?
Thanks
The problem is that you're specifying:
<a ... data-url="false" .../>
Twitter reads this value as the URL you're wanting to share, and is ultimately under the impression that the URL "false" has been shared 2,197 times. If you want to share a static URL, this attribute must relate to the URL of the page you're wanting users to Tweet about. If your page was http://example.com, for instance, you'd use:
<a ... data-url="http://example.com" .../>
(Which has been shared 1,492 times).
If you want to share the URL of the page the button is added to, you'd simply remove the data-url parameter altogether:
<a href="https://twitter.com/share"
class="twitter-share-button"
data-lang="en"
data-count="horizontal"
data-text="#{tw_listing(#data)}">Tweet</a>
If you need help with creating your Tweet button, you should refer to the official creation page at twitter.com/about/resources/buttons.

How can I use document.getElementById(someid).onclick for tag a

I want to automate to click on some link in a website.
since links on webpage are not direct link such as www.example.com/1.html.
it shows following link address for all the links I am interested in clicking
javascript:void(1)
following is the html code for that link I want to click
<a href="javascript:void(1)" onclick="server_playOn(17,2, 'est', this);">
Life OK
</a>
Once you've got a reference to the link you can just use the click method:
referenceToLink.click();

Share Dynamic Data on Facebook and Twitter

Is there some way to share some dynamic data from my page on facebook and twitter ?
I tried this code with static data and it worked, but I apply it dynamically it doesn't.
For Twitter:
<a href="http://twitter.com/share"
data-url="http://your.url.com/yourdynamicpage"
class="twitter-share-button"
data-text="What should I share?"
data-count="horizontal">Tweet</a>
For Facebook:
<img src="/path/to/your/image/" width="12" height="12" alt="alt" />
What am I doing wrong?
http://shantacreations.com/facebook_share_old/example_1/share.php/
yes the above link are functioning as you would like to make function.

Facebook Share not picking full url & meta name for custom url

I am trying to share a page of user on FB by giving the full url of that page. But it's not picking any title & other OG meta tags, which I have given on the page.
here is what I am using :-
<div class="img">
<a href='http://www.facebook.com/sharer.php?s=100&p[url]=https://pad.panda.org/content /nav_content.cfm?uNC=86290929&uXNavID=123906' target="_blank" onclick="javascript:window.open(this.href,
'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;">
<img src="images/facebook.jpg" alt="FaceBook" />
</a>
Try to get rid of all warning in the Facebook Debug Tool.

Categories

Resources