Home > Web Front-end > JS Tutorial > body text

Native javascript realizes the function of sharing to friends circle and supports ios and android_javascript skills

WBOY
Release: 2016-05-16 08:59:54
Original
4883 people have browsed it

There are many mainstream sharing tools now, such as JiaThis, bShare sharing, and even some big companies such as Baidu sharing, but they still only share on the PC side, and the support for mobile phones is not very good.

Everyone knows that many mobile browsers now have some built-in sharing components, such as UC Browser and QQ Browser. The built-in component sharing can directly start the corresponding APP sharing. If a JS can call the browser's built-in sharing Components, how cool is that.

Experts are among the people. The editor of Script House below will take you to take a look at the JS library written by this brother.

1. Tool introduction nativeShare.js

A tool that can directly call native sharing through javascript. This tool has the following characteristics:

1. Support native Weibo, WeChat friends, WeChat Moments, QQ friends, and QQ space sharing
2. Support calling more sharing functions of the browser
3. Does not rely on any jquery or other plug-ins
Note: Currently only mobile UC browser and QQ browser are supported

github project address: https://github.com/JefferyWang/nativeShare.js
Git@OSC project address: http://git.oschina.net/wangjunfeng/nativeShare.js

2. How to use

1.Introduce CSS files

Copy code The code is as follows:


2. Insert the following code where you need to add sharing:

Copy code The code is as follows:


3. Add configuration information and instantiate

Copy code The code is as follows:

<script><br> var config = {<br>             <a href="'http://blog.wangjunfeng.com',//">url:'http://blog.wangjunfeng.com',// Shared web link<br>             title:'Wang Junfeng's personal blog', // title<br> desc:'Wang Junfeng's personal blog',//Description<br> img:'http://www.wangjunfeng.com/img/face.jpg',// Picture<br>            img_title:'Wang Junfeng's personal blog',//Picture title<br> ​​​​from:'Wang Junfeng's Blog' // Source<br> };<br> var share_obj = new nativeShare('nativeShare',config);<br> </script>

3. Demonstration screenshots

Native javascript realizes the function of sharing to friends circle and supports ios and android_javascript skills
Figure 1: Share to Sina Weibo

Native javascript realizes the function of sharing to friends circle and supports ios and android_javascript skills
Figure 2: Share to WeChat Moments

Native javascript realizes the function of sharing to friends circle and supports ios and android_javascript skills
Figure 3: Share with contacts on WeChat

Native javascript realizes the function of sharing to friends circle and supports ios and android_javascript skills
Figure 4: QQ sharing to contacts

Native javascript realizes the function of sharing to friends circle and supports ios and android_javascript skills
Figure 5: QQ sharing to space

Native javascript realizes the function of sharing to friends circle and supports ios and android_javascript skills
Figure 6: Calling the browser’s built-in sharing component

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template