html - 图片在网页上损坏,但在其他地方测试时有效

标签 html css

我有一个应该显示 Facebook 图标的简单代码块:

<div class="icon">
    <a href="http://www.facebook.com" onclick="window.open(' https://www.facebook.com/','newwindow','width=600, height=300');return false;">
        <img src="https://content.t-three.co.uk/hubfs/tp-2017/Template%20refresh/Littlebooks/facebook.png" alt="Facebook"/>
    </a>
</div>

在页面上,它显示为损坏的图像,但是当我测试了 JSFiddle 中的代码时, 有用? (图像是白色的,可能需要拖动图像才能看到)。

为什么会这样?

编辑:

这是测试页的[预览链接][2]。

最佳答案

现在有了链接就更容易了,你已经混合了安全和不安全的内容(即 http 和 httpS)。转到浏览器的开发人员工具(通常是 F12 键),您将看到以下错误:

Mixed Content: The page at 'https://preview.hs-sites.com/_hcms/preview/template/multi?is_buffered_template_layout=true&portalId=1870680&tc_deviceCategory=desktop&template_layout_id=5498485491' was loaded over HTTPS, but requested an insecure image 'http://content.t-three.com/hubfs/Images/Templates/Landing_Page/facebook.png'. This request has been blocked; the content must be served over HTTPS.

它要么都需要是“http”或“https”,你不能混合这两者。你的浏览器认为你在​​安全页面上加载不安全的内容。

所以:

<img src="httpS://...

关于html - 图片在网页上损坏,但在其他地方测试时有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48093470/

相关文章:

html - 在容器 div 中对齐按钮链接

javascript - 如何通过检查元素的子元素是否具有特定的类名来将 css 属性添加到元素的伪类

单击更改正文不透明度的jquery

javascript - jQuery 列添加排序

javascript - 使用 JavaScript 或 jQuery 突出显示文本

html - 如何在 :after 元素后创建箭头形状

javascript - .click 不适用于更改选项卡容器的高度

html - 将开放 XML 的 XSLT 转换为干净的 HTML 列表

jquery - 时间选择器的问题

javascript - 如何在没有 JavaScript 的情况下分离键盘 Tab 键旋转组?