如何在 IE9 中使用协议相关 URL?
更新
这既不是 IE9,也不是插件。这是使用该插件的人的错误。
原始问题
我在 example.com/image.png
上有一个图像,我想在 HTTP 和 HTTPS 页面上的 Javascript 插件中使用它。该插件目前将 URL 设置为
//example.com/image.png
大多数浏览器都会将其正确转换为 http://example.com/image.png
或 https://example.com/image.png
。然而,当通过 HTTPS 在 IE9 中查看页面时,URL 会变成 https:////example.com/images.png
。也就是说,IE9 会在前面加上 "https://"
,而不仅仅是 "https:"
。如何让 IE9 正确处理协议相关 URL?
UPDATE
This was neither IE9 nor the plugin. It was the fault of the person using the plugin.
Original Question
I have an image at example.com/image.png
that I'd like to use in a Javascript plugin on both HTTP and HTTPS pages. The plugin currently sets the URL to
//example.com/image.png
Most browsers turn that into http://example.com/image.png
or https://example.com/image.png
propertly. When the page is viewed in IE9 over HTTPS, however, the URL gets turned into https:////example.com/images.png
. That is, IE9 prepends "https://"
, not just "https:"
. How do I get IE9 to properly handle protocol-relative URLs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您无法找出发生了什么,那么您可以通过将
location.protocol + url
传递给插件而不是仅url
来轻松地自行解析 url。If you cannot find out what is happening then you can easily resolve the url's yourself by passing
location.protocol + url
to the plugin instead of justurl
.