时间:2022年03月28日 12:03:00分类:问答
很多网站都使用了百度分享这个前端分享插件,不过百度分享官网代码并不支持https,目前官网网址已经跳到了百度搜索资源平台,估计是百度已经废弃了这个分享插件。现在越来越多的网站安装上了SSL证书,启用https访问网站,如果不想使用其他分享插件来取代百度分享的话,该如何改造百度分享使其支持https呢?
在百度上搜索了一番发现,已经有人把百度分享的代码重新封装后放在了github上了。github下载地址:https://github.com/hrwhisper/baiduShare
将github上的百度分享代码下载下来,将解压的的static文件上传到网站的根目录。
然后找到百度分享js代码,类似如下部分,将其中的红色部分http://bdimg.share.baidu.com删掉即可。
<script>window._bd_share_config = {"common": {"bdSnsKey": {},"bdText": "","bdMini": "2","bdMiniList": false,"bdPic": "","bdStyle": "0","bdSize": "16"},"share": {}};with( document ) 0[ ( getElementsByTagName( 'head' )[ 0 ] || body ).appendChild( createElement( 'script' ) ).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~( -new Date() / 36e5 ) ];</script>
Copyright © 2020-2021 鸿翼博客 hongyisheji.cn All Rights Reserved.站点地图
鄂ICP备11004285号-2