Git Product home page Git Product logo

js-share's Introduction

JS Share

Simple JS script for sharing links on social networks. It will get the current URL or you can set it manually.


Overview

This script was built to help to deterine where your users mostly share your content. You can pass a callback function to the script, and it will return a event label for you to send in your Google Analytics or Facebook Pixel or whatever you want. This can help you to see which social media your public likes the most.

It also have a WhatsApp floating Widget

It also have the Share Web API for mobile (be sure to make your website https, otherwise it won't work)


How to use

Just load the script and the css on your HTML page, and then use:

<div id="someElementId"></div>
<script>
Share.init({element:someElementId})
</script>

The script will render and append the generate HTML to the given element.


Parameters

You can pass an object to set the wrapper element, set/unset which social media you want your public to share, set if you want the social media name on its button, set if you want a button to show the options, set the URL and more stuff.

Here's an example:

<script>
Share.init({element:shareWrapper,withText:false,withButton:true,shareButtonText:'share',withWindow:true,facebook:false,url:'https://mycustomurl',onShare:function(label){
        console.log(label);
      }});
</script>

You can set the WhatsApp widget with a string number, or an array of numbers. You can also set a corner side with "left" or "right" (default is "right") Here's an example:

<script>
Share.createFloatingWhatsAppWidget("{phone Number Or array number goes here}","left");
</script>

Enjoy!

js-share's People

Contributors

matheus2212 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.