桌面网页上实现分享功能,分享到QQ空间、新浪微博、人人网

JS实现:HTML页面一键分享到微博、QQ空间、QQ好友 阅读详情

重要声明:本文章仅仅代表了作者个人对此观点的理解和表述。读者请查阅时持自己的意见进行讨论。

本文原文地址:桌面网页上实现分享功能,分享到QQ空间、新浪微博、人人网

在桌面网页上发现好文章时用户往往选择分享给朋友,而这时我们如何实现分享呢,本文列出了分享到:QQ、QQ空间、新浪微博、人人网 的api和分享代码。你不必再去到处找了。

1、分享到QQ

API接口:https://connect.qq.com/widget/shareqq/index.html

参数:

字段含义
url要分享的地址
title分享标题
source分享内容的来源,常常就写主站的首页地址
summary要分享的内容描述
pics分享时的图片
desc分享时的预置文案,就是会紧接着一另一条消息发给好友的内容

2、分享到QQ空间

API接口:https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey

参数:

字段含义
url要分享的地址
title分享标题
site分享内容的来源,常常就写主站的首页地址
summary要分享的内容描述
pics分享时的图片
desc分享时的预置文案,相当于你发空间时写的内容

3、分享到新浪微博

API接口:http://service.weibo.com/share/share.php

参数:

字段含义
url要分享的地址
title分享标题
appkey新浪微博的appkey
pic分享时的图片

4、分享到人人网

API接口:http://widget.renren.com/dialog/share

参数:

字段含义
resourceUrl要分享的地址
srcUrl分享内容的来源,常常就写主站的首页地址
title分享标题
description要分享的内容描述
pic分享时的图片

5、代码

下面的代码封装了所列出的所有分享,你可以直接COPY,代码里包含了本站的首页地址,复制的时候记得改成自己的站点地址哦:

var ShareUtil = {
    openShareUrl: function (url) {
        var a = document.createElement("a");
        a.href = url;
        a.target = "_blank";
        a.click();
    },
    shareToQQ: function (option) {
        var url = "https://connect.qq.com/widget/shareqq/index.html" +
            "?url="     + encodeURIComponent(option.url)      +
            "&title="   + encodeURIComponent(option.title)    +
            "&source="  + encodeURIComponent('https://www.microanswer.cn')   +
            "&summary=" + encodeURIComponent(option.desc)     +
            "&pics="    + encodeURIComponent(option.pics)     +
            "&desc="    + encodeURIComponent(option.summary);
        ShareUtil.openShareUrl(url);
    },
    shareToQZone: function (option) {
        var url = "https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey" +
            "?url="     + encodeURIComponent(option.url)      +
            "&title="   + encodeURIComponent(option.title)    +
            "&summary=" + encodeURIComponent(option.desc)     +
            "&desc="    + encodeURIComponent(option.summary)  +
            "&site="    + encodeURIComponent('https://www.microanswer.cn')     +
            "&pics="    + encodeURIComponent(option.pics);
        ShareUtil.openShareUrl(url);
    },
    shareToWeibo: function (option) {
        var url = "http://service.weibo.com/share/share.php" +
            "?url="     + encodeURIComponent(option.url)      +
            "&title="   + encodeURIComponent(option.title + "。" + option.desc)    +
            "&pic="     + encodeURIComponent(option.pics)     +
            "&appkey="  + encodeURIComponent(option.appkey);
        ShareUtil.openShareUrl(url);
    },
    shareToRenren: function (option) {
        var url = 'http://widget.renren.com/dialog/share' +
            '?resourceUrl='    + encodeURIComponent(option.url) +
            '&srcUrl='         + encodeURIComponent('https://www.microanswer.cn') +
            "&title="          + encodeURIComponent(option.title)    +
            "&description="    + encodeURIComponent(option.desc)     +
            "&pic="            + encodeURIComponent(option.pics);
        ShareUtil.openShareUrl(url);
    }
}

然后你就可以使用 ShareUtil 里面的方法进行分享啦。记得为此博文点赞分享哦。

JS分享代码 全功能 支持facebook twitter等 JS分享代码 全功能 支持facebook twitter等 可结合移动端页面! 立即下载

相关推荐

页面选中文字分享到新浪微博

NULL 博文链接:https://axl234.iteye.com/blog/1532434

如何实现安卓屏幕分享及视频聊天?(源码)

// 视频请求 0/// 回复视频请求的结果 1/// 通知对方 挂断 视频连接 2/// 通知好友 网络原因,导致 视频中断 3/// 通知对方(忙线中) 挂断 视频连接 4/// 屏幕分享请求 5/// 回复屏幕分享请求的结果 6/// 主动取消屏幕分享请求/// 对方(主人端)主动断开屏幕分享/// 客人端断开屏幕分享这里我们定义了为了实现第一部分“功能介绍”中的功能,所需要用到的消息类型。

Gefangenes的博客 779

js页面文字选中后分享到新浪微博实现

NULL 博文链接:https://axl234.iteye.com/blog/1317778

网页共享电脑屏幕与播放(带声音)

获取媒体的方式不止这一个,还有其他方法方法可以看MDN文档上搜MediaDevices来看API具体了解,这个带声音的共享屏幕功能我也是百度了好久,也没有一篇博客完整的说一下方法,所以还是多看一些官方文档,去了解一些具体的用法。虽然官方文档中有共享屏幕的方法,但是它只有共享屏幕和获取摄像头的权限,并不能把声音给添加上去,只能通过另一种方式来操作,下面就看一下完整的代码。上边的代码是可以在任何浏览器端共享屏幕都有声音的,不过其中有一个方法不用添加音频轨道,浏览器会自动为我们添加,就是火狐浏览器,

YX0711的博客 2421

UReport2 报表设计器 在线表格

UReport2官网 一、UReport2报表设计器 UReport2是一个开源的可视化报表设计器,功能强大,操作简单,可以实现复杂的报表统计,有各种各样的导出和打印功能,支持导入Excel表格! 1、报表设计器 2、设计一个简单的用户列表展示 二、可编辑表格 扩展了layui的表格,支持多元化数据编辑(单选,多些、日期、下拉联动),开发简单、高效、便捷。有了它就可以轻松开发类似进销存系统的表格录入功能了,用户拿来即用! 三、主从表录......

ejinxian的专栏 2万+

CAN 比特率和采样点计算

架构根据输入频率和比特率自动计算。

ldinvicible的专栏 787

【网页分享到微博、微信、qq空间、qq】

网页分享常见社交平台

qq_42221321的博客 1218

SecOC专题之新鲜值TripCnt

本系列为一步步拆解新鲜值的分发及管理而撰写文章属于原创,根据自身开发经验及理解撰写,若有错误请指出Trip Counter是新鲜值中变化最慢的一个part,并且自增到最大值时,会从头开始翻转计数。Trip Counter需要收发双方都保存,由于其变化较慢,所以不会经常进行同步该值。这就要求开发过程中保证每次对该值的读写必须要正确。

qq_22969363的博客 1154

2024年HTML+CSS+JS 网页版烟花代码

直接跳到末尾。

努力是为了站在万人之中,成为别人的光 8562

ESP32设备驱动-直流电机与L298N电机驱动器

在本文中,我们将介绍如何使用ESP32通过L298N电机驱动器驱动直流电机。

视觉与物联智能 3594

【同等学力】2005-数学⭐✨

有r个正方形排成一行,今用红、黄、白、蓝四种颜色给这个r个正方形染色,每个正方形只能染一种颜色,如果要求染红、黄、白色的正方形分别至少出现一个,问有多少种不同的染法?3、(4分)设G是一个有n个结点m条边的连通简单平面图,若n≥3,则m≤3n-6.4、(4分)证明:任何连通简单平面图至少有一个结点的度数不超过5

super_mochi1 306

php分享到qq空间实现,桌面网页上实现分享功能,分享到QQ空间、新浪微博、人人网...

重要声明:本文章仅仅代表了作者个人对此观点的理解和表述。读者请查阅时持自己的意见进行讨论。在桌面网页上发现好文章时用户往往选择分享给朋友,而这时我们如何实现分享呢,本文列出了分享到:QQ、QQ空间、新浪微博、人人网 的api和分享代码。你不必再去到处找了。1、分享到QQAPI接口:https://connect.qq.com/widget/shareqq/index.html参数:字段含义url要...

weixin_42394913的博客 476

【深度学习】什么是自回归模型?

自回归模型是一种重要的时间序列模型,通过利用过去的值来预测当前或未来的值。它在统计学、经济学、自然语言处理等领域有广泛的应用。自回归模型的简单性和可解释性使其成为许多应用的首选,但在更复杂的情况下,可能需要结合其他模型如移动平均模型(MA模型)或混合模型(如ARIMA)来更好地捕捉时间序列中的模式。扩散模型(Diffusion Model)和自回归模型(Autoregressive Model)是两种不同的生成模型,各自有独特的特点和应用场景。

q742971636的博客 1671

中国互联网开放平台一览

百度搜索开放平台 - open.baidu.com   百度开放平台是基于框计算先进技术和服务理念,而提供的开放数据分享暨对接平台。通过该平台,广大站长和开发者可以提交结构化的数据或资源,并在搜索结果中直接展现。对用户而言,只要在“框”中输入服务需求,系统就能准确识别,并将其分配给最优的内容提供者,最终返回给用户最精准的结果。这种智能的互联网需求交互模式,以及简单可依赖的实现机制,称之为“框计算...

iteye_13088的博客 2533

海思芯片YOLOv8模型部署完整指南:从RPN硬化到8bit量化精度优化

本文详细介绍了在海思芯片平台部署YOLOv8目标检测模型的完整方案,重点解决8bit量化精度损失问题。通过分析海思RPN硬化层的性能优势(1.9ms推理时间),对比不同量化策略(16bit仅损失0.6AP,8bit损失5.2AP),并深入定位到strides计算层是量化误差的主要来源。关键突破在于采用混合精度策略(敏感层16bit,其余8bit),使8bit量化AP回升4.1%,同时保持3.4ms的推理速度和60%的低NPU占用率。文章还提供了量化参数调整、校准数据集优化等进阶技巧,为边缘计算应用提供了性能

FJN110的博客 732

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

微博html5到桌面,HTML 分享页面到QQ/微信、微博等平台

详细的代码示例(完整的分享媒体id对应表详见转载链接) //QQ空间 //新浪微博 //百度 //人人网 //QQwindow._bd_share_config = {common : {bdPopTitle:'窗口标题',bdText : '发现一个新的网页,快来围观啊~',bdDesc : 'Custom share summary', //自定义分享摘要bdUrl : 'Custom ...

weixin_42350755的博客 675

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

RSS阅读器Web的更好用

RSS阅读器很早就出现了,有的内嵌于浏览器和邮件收发工具,还有独立的桌面应用程序,如周博通、看天下、新浪点点通等,然而并没有得到普遍应用。直到Web2.0时代来临,订阅好友的博客可以第一时间看到日志更新,也可以说是博客成就了RSS。各种应用程序逐渐推出Web版,RSS阅读器也不例外,这样无需安装任何软件或者插件。     独立的Web版RSS阅读器是比较新的形式,具有代表性的是GoogleRe

Angiexia的专栏 1411

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

怎么安装Win10,硬盘安装Win10系统图文教程

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33966365的博客 227

快捷键的使用

分享到 一键分享 QQ空间 新浪微博 百度云收藏 人人网 腾讯微博 百度相册 开心网 腾讯朋友 百度贴吧 豆瓣网 搜狐微博 百度新首页 QQ好友 和讯微博 更多... 百度分享 百度经验 | 百度知道 | 百度首页 | 登录 | 注册 新闻 网页 贴吧 知道 经验 音乐 图片...

weixin_30299539的博客 191

网页分享到微信、微博、QQ等

首先要说明的是,pc端微信分享只能通过二维码来分享。 部分代码如下: //分享到新浪微博 function shareToSinaWB(event){ event.preventDefault(); var _shareUrl = 'http://v.t.sina.com.cn/share/share.php?&appkey=895033136';

小田同學的博客 1万+

将网页分享到qq,微信,微博

原文地址:https://zixuephp.net/article-309.html 效果 分享到微博 使用到的接口(测试时需要登录,网址和图片必须是公网的,不能localhost): 1.分享到QQ空间接口:https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=你的网址&sharesource=...

weixin_43856422的博客 7233

h5pc端分享当前网页到qq、微博

直接使用 a 链接跳转到平台的分享页面就行了,效果如下

weixin_54000091的博客 971

如何实现分享网页中的文本到微博

window.open("http://v.t.sina.com.cn/share/share.php?title="+txt; txt为你要发送的html文本

mhHao的博客 1426

pc端分享到微信、微博、facebook、twitter

pc端分享到微信、微博、facebook、twitter

weixin_56388927的博客 3244

不用微博SDK,直接使用 新浪微博 分享链接进行分享

目前有个需求,就是想从APP和网页中分享一个网页到新浪微博,很简单,可以网页侧APP侧接入微博的SDK,但我不想,太麻烦,就是分享一个功能,加入太浪费了。 基本方案, 使用https://service.weibo.com/share/share.php 进行分享 参数: url : 要分享的链接 title: 文字 pic: 分享的图片的url 上述参数都要转码 例 https://service.weibo.com/share/share.php?url=http%3A...

小流星子学习博客 1万+
上一篇: 【Java】使用Timer实现的定时任务,支持按规则执行。
下一篇: 【Vue】使用Vue实现div收缩效果
Microanswer
博客等级 码龄10年 38粉丝 40原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值