javascript - 将 HTTP 链接添加到 SSL HTTPS 页面而不会导致混合内容 "Not Secure"错误

标签 javascript html

如何在此页面上添加不安全的 HTTP 链接而不导致“不安全”错误?

  • 我有一个使用 SSL HTTPS 的安全网页。
  • 此网页是一个包含 100 多个按钮的仪表板,所有按钮都包含外部网站的链接。
  • 不幸的是,并非所有这些网站都支持 HTTPS ...2020 年很常见!

有没有办法在保持网站锁定的同时解决这个问题?

尝试 #1

<link rel="ampHtml" href="http://example.com/">

尝试#2

I used TinyURL to convert my HTTP links into short URLs which have HTTPS. ...this works for most of the links (which is great!)

The remaining links when clicked have additional Javascript which is adding URL querystrings to the end of the URLs. These strings apply on the TinyURL successfully, but does not on the final destination URL.

我能想到的唯一其他解决方案(如果可能的话)是......

  • JavaScript 在打开新标签页和加载网站之前将特定链接 onClick 转换为 HTTP。
  • 用于延迟 HTTP 链接加载的 JavaScript。

最佳答案

您可以制作重定向页面。最基本的方法是使用 JavaScript 制作重定向页面。

if (window.location.search.includes("?url=")) {
  var url = window.location.search.replace("?url=", "");
  window.location.replace(url);
}

基本上,发生的事情是它从安全页面重定向到非安全页面,而不会导致“混合内容”错误。它从 window.location.search 获取 url 参数,然后重定向到该参数。

关于javascript - 将 HTTP 链接添加到 SSL HTTPS 页面而不会导致混合内容 "Not Secure"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61093408/

相关文章:

javascript - 停止 iframe 在悬停时重新加载

javascript - Firebase 云功能 promise

javascript - 为什么饼图在 D3 中开始从不同 Angular 绘制?

html - 自闭标签后的 Jade 内容

javascript - pdfmake - 在 ANGULAR 4 中将 SVG 转换为 image64

javascript - 我需要显示一条折线,其中包含从数据库动态获取的一组点,精确地捕捉到道路

javascript - Open Layers 无法读取未定义的属性 'add Layer'

javascript - 如何检查一个 Div 是否为空然后执行操作

html - 在 Angular2 模板的表达式中使用 JSON.stringify

javascript - 检查是否加载了内联 SVG 图像