AddThis Share : LinkedIn always open in new window - linkedin

We're using AddThis Social Share functionality with our Sitecore/MVC application. The problem we're facing is that the LinkedIn share always opens in new window. On Inspect, we can see the target=_blank in code, which is not being added in our code.
Any help?
Thanks,
Chandana

The behavior of each share button is as per the website to which the page is being shared. If you test each button (say Facebook, G+, Twitter, LinkedIn, etc.) you will notice that they all work differently. It's not AddThis choice. This is because each website has its own API and that's the way that website decided it would work with their system. LinkedIn happens to open a separate window... Pinterest first opens a popup within your page and then another window after you selected the image you wanted to share. G+ and Facebook open a new tab. And the popups/windows all look quite different, but the users should recognize each respective brand as a result...

I suspect that this is a problem with the AddThis Social Share functionality. To share on LinkedIn, all you need is the following URL format...
https://www.linkedin.com/sharing/share-offsite/?url={url}
Then you can setup your <a href="..."> element however you like, with target="_blank" or not.
Source: Official LinkedIn Sharing Documentation.

Can try out below JavaScript code, which will overwrite addthis functionality, and make linkedIn as popup,
setInterval make sure click event attached to dynamically generated anchor tag
$(document).ready(function () {
var clickinterval = setInterval(setclickevent, 500);
function setclickevent() {
if ($('.at-svc-linkedin').length > 0) {
$('.at-svc-linkedin').on('click', function () {
window.open('https://www.linkedin.com/sharing/share-offsite/?url=' + fixedEncodeURIComponent(window.location.href), 'popup', 'width=600,height=600');
e.preventDefault();
return false;
});
clearInterval(clickinterval);
}
}
function fixedEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16);
});
}
});

Related

Google sign in custom button

I migrated from https://apis.google.com/js/client:platform.js to https://accounts.google.com/gsi/client. I need to use a my custom google login button in order to have similar UX with other buttons.
How can I do it?
Google button works but it is rendered using google style.
window.onload = function () {
google.accounts.id.initialize({
client_id: "xxxxxxxxxxxxxxxx",
callback: handleCredentialResponse
});
google.accounts.id.renderButton(
document.getElementById("glogin"),
{ type: "icon", size: "medium" } // customization attributes
);
//google.accounts.id.prompt(); // also display the One Tap dialog
}
My custom html button is:
<li id="glogin"><img src="assets/images/land_login/auth_google.png" alt=""></li>
Please help me. I can't found solution on google official documentation.
I faced same issue and it seems we cannot use custom button with gsi.
However, you can modify iframe render button by using given options.
It was not enough to me btw.
If you go with html api, you can generate Html code.
If you go with javascript api, you can check the options here.
I am trying this node package now. I will let you know if it works.

Whatsapp share link not working from mobile

I am using aspx to initialize the whatsApp click to chat feature to share a link.
The aspx code is :
The link was working fine. I was able to share the link. But in the recent months i am not able to share the link as i get a message from whatsapp in my mobile displayed as
Couldn't open link
Screen Shot:
NOTE: I am able to share from web browser but not from my mobile.
Is there anything wrong in the syntax or has whatsapp updated their feature, but i dont think so as their docs are still having the same info ?
Edit: The output url looks like this in chrome inspector:
https://wa.me/?text=https%3a%2f%2fwww.website.com%2fblog%2fPageName.aspx%3fblog%3dtitleword-your-titleword-system-using-titleword%26id%3d10%26temp%3dq
For computers, you will want to use this link...
https://api.whatsapp.com/send?text=YourTextHere
Otherwise, if you use wa.me, you will get an error page, unless you have the phone number included. For example, this links to an error: https://wa.me/?text=SomeTexttoShare
Typically, you don't know the number, and you want the user to specify. In that case, you MUST use the api.whatsapp.com domain.
I tried the same link in different android browser(FireFox) and it was working fine.
For chrome i changed the link to this -> whatsapp://send?text=
My code:
string WhatsappShareURL = "whatsapp://send?text=" + Request.Url.AbsoluteUri;
hlWhatsappMobile.NavigateUrl = Server.UrlEncode(WhatsappShareURL);
For Computers:
I use this link -> https://wa.me/?text=
My code:
string WhatsappShareURL = "https://wa.me/?text=" + Request.Url.AbsoluteUri;
hlWhatsappWeb.NavigateUrl = Server.UrlEncode(WhatsappShareURL);
Then i toggle them in jquery:
$(document).ready(function () {
if ($(window).width() < 520) {
//Show mobile link
}
else {
//Show Web link
}
});

Dojo 1.10 iFrame to access another website

I am new to DOJO and have a requirement where in we need to embed already running website on our new website using an iframe. Both websites will be running on same domain.
I tried using dojo/request/iframe, and am able to see the website in my iframe BUT when clicking on any of the link in embedded website, it opens in another window. But i want it to work in my iframe internally.
Below is the code snippet:
<script>
require(["dojo/request/iframe", "dojo/dom", "dojo/dom-construct"], function(iframe, dom, domConst){
iframe("http://localhost:8080/phpkbv8/", {
handleAs: "html"
}).then(function(data){
var greetingNode = dom.byId('siteInclude');
domConst.place(data.documentElement,greetingNode);
}, function(err){
var greetingNode = dom.byId('siteInclude');
domConst.place('<p>Error Occured!!!</p>' + err,greetingNode);
});
// Progress events are not supported using the iframe provider
});
</script>
Please help me in making it work. Looking for help.
If you are intending to embed an iframe into your page for display/interaction purposes, you shouldn't really be using dojo/request/iframe to do so. If you need to create the iframe programmatically, use DOM APIs or dojo/dom-construct. For example, based on your code above:
domConst.create('iframe', {
src: 'http://localhost:8080/phpkbv8/'
}, greetingNode);
dojo/request/iframe is specifically intended as a transport for sending Ajax requests, in cases where XHR, script injection, etc. aren't sufficient.

How to incorporate Google Analytics Event Tracking with Anythingslider

I am looking for some clues on where to add Google Analytics Event Tracking to a page that has AnythingSlider installed. I have a slider that does not autoscroll and you have to click the navigation buttons for the slides to move. I wish to track these clicks. I would also like to track if a visitor clicks on a link within a slide.
I am wishing to use Google's InPage Analytics to track visitor click behavior and workout what items (images & phrases) catch the attention of the visitor in order to make better lead funnels.
I did try the Event tracking guide from Google before posting here, but I was unsure of where to pickup the navigation clicks from the slider.
add this to any a href in your html
onClick="_gaq.push(['_trackEvent', 'Slider','Panelno:x', 'blah']);"
Untested (I'm about to do this myself) but the API suggests to me that I should use the onSlideComplete callback, e.g. (assuming you've set up the names of your panels in an array called pages).
onSlideComplete : function(foo) {
_gaq.push(['_trackEvent', 'Slider','Panelno:'+slider.currentPage, pages[index - 1]]);
}
EDIT: Be careful with onSlideComplete, it seems to fire off too often. Set a var to tell it not to refire, and reset the var with onSlideBegin.
onSlideBegin : function(e, slider) {
refire = 1;
},
onSlideComplete : function(slider) {
if (refire) {
_gaq.push(['_trackEvent', 'Slider','Panelno:'+slider.currentPage, pages[slider.currentPage - 1]]);
refire=0;
}
}

How to embed "Share on Facebook" button into Flex application?

I'm trying to duplicate the behaviour of the "Share on Facebook" button from Youtube. Basically, inside a Flex app I'll have a button and when I click it I want a popup that enables me to post something on the wall.
While it is possible to make a call to javascript to open the pop-up I want to be able to set the images and the text of my posting.
Do you know how I could set the images or text as a paramter to the sharer window?
Thank you!
This is fairly straightforward to do. Youtube uses the Facebook API which pops up a new window (Info on Facebook sharer API).
To do this in flex,
Create a button that onClick will call a javascript method, ExternalInterface.call("fbLink", "www.yahoo.com");
In your HTML file (most likely index.template.html) add the JavaScript method, fbLink which does the following:
function fbLink(url) {
window.popup("http://www.facebook.com/sharer.php?u=" + url, {height:440, width:620, scrollbars:true})
}
Now when a user clicks on the button they will be sharing the link "yahoo.com" with facebook account.
as I understood you asking for some help in accessing js popup in html page of facebook share button, so you should use ExternalInterface in this casa and access needed DOM node using getElementById function in your js interface.
In other case I want propose you to read another one way http://www.riaxe.com/blog/flex/publish-into-facebook-wall-from-flex/
It seems that you want to have a button on the flash application and once clicked it opens the facebook page that shares the video/image that pertains to the clicked button. What you want to do is simply create a button that on click opens a new website to facebook using their share api which has the following format:
var facebookShare:String = "http://www.facebook.com/share.php?u=' + encodedVideoLink + '&t='+ encodedVideoText";
Where the u parameter stands for the link that you wish to share, and the t parameter stands for the title of the piece that you want to share, whether it be a picture or video.
You want to add an event listener on MouseEvent.CLICK that has as its callback function a method that handles the opening of the facebook page passing the facebookShare variable as shown above. To open another page on your browser you can use this AS3 Class called URLNavigator: http://www.danishmetal.dk/project/source/com/zorked/URLNavigator.as
To sum it up, something along these lines would do:
var facebookShare:String = "http://www.facebook.com/share.php?u=' + encodedVideoLink + '&t='+ encodedVideoText";
facebookButton.addEventListener(MouseEvent.CLICK, this._goToUrl(facebookShare));
private function _goToUrl(link:String):Function {
var window:String = "_blank",
feats = "",
thisOverlay:Object = this; // to not lose scope when returning a func
return function (e:MouseEvent):void {
trace("Opening link to:"+link);
try { URLNavigator.ChangePage(link, window, feats); }
catch (e:Error) { trace("error launching "+link+" in "+window+" with feature set "+feats); }
}
}
I hope that helps. If you have questions regarding the code please let me know.

Resources