Social sharing JavaScript API functions

šŸ“˜

The content on this page deals with a legacy feature of the ā€‹Akamaiā€‹ Identity Cloud (in this case, social sharing). If you are currently an Identity Cloud customer and are using social sharing, that feature is still supported. However, if youā€™re new to the Identity Cloud, social sharing is no longer available.


The Social Sharing solution supports client-side functions that allow you to dynamically load the sharing widget to a page after it has been loaded. Use theĀ janrain.socialĀ method after theĀ janrainSocialOnLoadĀ function has been called to attach the share tool to an HTML element.


.addWidgetTo(element, options)

This method will accept anĀ elementĀ toĀ optionsĀ mapping.Ā The elementĀ is required and refers to the HTML element to which the sharing widget should be attached.Ā optionsĀ is an optional JavaScript object containing settings that will override anything currently set on the element in theĀ data-janrain-*Ā attributes. See theĀ Social sharing JavaScript API instance settings for a list of valid keys that may be used. Do not include theĀ data-janrain-*Ā prefix. Use camelCase.

Example using JavaScript to create a new element, with options:

<script type="text/javascript">
 vare = document.createElement("div");
 document.body.appendChild(e);
 janrain.social.addWidgetTo(e,{url:"http://twitter.com",formFactor:"drawer"});
</script>

Example using JQuery to create a new element, without options:

<script type="text/javascript">
 varplaceholder = $("<div></div>")
 .attr("data-janrain-url","http://bing.com")
 .appendTo(document.body);
 janrain.social.addWidgetTo(placeholder[0])
</script>

Example using JQuery to add the share widget to an existing element (the lastĀ janrainSocialPlacholderĀ element on the page):

<script type="text/javascript">
 janrain.social.addWidgetTo($(".janrainSocialPlaceholder").get(-1),{url:"http://bing.com"})
</script>