development

https网站内嵌百度地图服务

By jere on 2016-02-24 0 Comments

接上篇,如果我们的网站从http切到了https, 刚网站用的其他的例百度地图也需要使用相应的https协议,包括CDN缓存。

在使用百度地图时,官方文档只告诉我们用 <script type=”text/javascript” src=”https://api.map.baidu.com/api?v=2.0&ak=密钥”></script>。但这个api会render带有http的内容,进而报错。
Mixed Content: The page at ‘https://xxxx.com/xxx/xxx’ was loaded over HTTPS, but requested an insecure script ‘http://api.map.baidu.com/getscript?v=2.0&ak=密钥&services=&t=20160224094302’. This request has been blocked; the content must be served over HTTPS.

正确的使用方法是,需要增加额外参数s=1
<script type=”text/javascript” src=”https://api.map.baidu.com/api?v=2.0&ak=密钥&s=1″></script>

打赏

Leave a comment

您的电子邮箱地址不会被公开。 必填项已用*标注