解决百度分享不支持https的方法

百度分享不支持https,解决方法是把百度分享本地化。

1、下载本地化文本:https://github.com/hrwhisper/baiduShare

baidusharehttps_01.png

2、把解压后的static文件夹上传到网站根目录(要有可访问权限)

3、修改百度分享的js代码,更改前的代码如下:

<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>

更改后的代码:

<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='/static/api/js/share.js?v=89860593.js?'];</script>

问题解决!

关键词: 分享代码