加载 js 脚本的 http 和 https
Loading both http and https for js scripts
我有一个应用程序,我可以使用 http 或 https 访问它们:http://www.test.com
和 https://www.test.com
在应用程序的 header 中,我加载了一个用于宣传的脚本:http://www6.smartadserver.com
.如果我使用 http 访问应用程序:宣传已加载。如果我使用 https 访问应用程序,我会收到错误消息:
The page at htttps://www.test.com was loaded over HTTPS, but requested an insecure script http://www.smartadserver.com. This request has been blocked; the content must be served over HTTPS.
在 header 的应用程序中,我有:
<script src='http://www6.smartadserver.com/config.js?nwid=11111' type="text/javascript"></script>
<script type="text/javascript">
sas.setup({ domain: 'http://www6.smartadserver.com', async: true, renderMode: 0, inSequence: true });
</script>
你能帮帮我吗?
试试这个方法:
<script src='//www6.smartadserver.com/config.js?nwid=11111' type="text/javascript"></script>
<script type="text/javascript">
sas.setup({ domain: '//www6.smartadserver.com', async: true, renderMode: 0, inSequence: true });
</script>
RFC 3986 的第 4.2 节提供完全限定的 URL 完全省略协议(HTTP 或 HTTPS)。当省略 URL 的协议时,浏览器将使用基础文档的协议。
因此,通常来说,您可以避免严格设置协议 - 浏览器会自动 select 它。
我有一个应用程序,我可以使用 http 或 https 访问它们:http://www.test.com
和 https://www.test.com
在应用程序的 header 中,我加载了一个用于宣传的脚本:http://www6.smartadserver.com
.如果我使用 http 访问应用程序:宣传已加载。如果我使用 https 访问应用程序,我会收到错误消息:
The page at htttps://www.test.com was loaded over HTTPS, but requested an insecure script http://www.smartadserver.com. This request has been blocked; the content must be served over HTTPS.
在 header 的应用程序中,我有:
<script src='http://www6.smartadserver.com/config.js?nwid=11111' type="text/javascript"></script>
<script type="text/javascript">
sas.setup({ domain: 'http://www6.smartadserver.com', async: true, renderMode: 0, inSequence: true });
</script>
你能帮帮我吗?
试试这个方法:
<script src='//www6.smartadserver.com/config.js?nwid=11111' type="text/javascript"></script>
<script type="text/javascript">
sas.setup({ domain: '//www6.smartadserver.com', async: true, renderMode: 0, inSequence: true });
</script>
RFC 3986 的第 4.2 节提供完全限定的 URL 完全省略协议(HTTP 或 HTTPS)。当省略 URL 的协议时,浏览器将使用基础文档的协议。
因此,通常来说,您可以避免严格设置协议 - 浏览器会自动 select 它。