且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

安全页面上 iframe 中的不安全内容

更新时间:2022-03-19 21:35:32

如果正在使用 https://www.example.com/main/index.jsp (SSL) 访问您的页面,则如果 HTML 代码中的任何资源使用 http://(非 SSL)引用,您的浏览器会抱怨此页面包含安全和不安全的项目".这包括 iframe.

If your page is being accessed using https://www.example.com/main/index.jsp (SSL) then your browser will complain with "This page contains both secure and insecure items" if there are any resources in the HTML code that are referenced with http:// (non-SSL). This includes iframes.

如果您的导航页面托管在同一台服务器上,那么您可以使用这样的相对 URL 来防止不安全内容"消息...

If your navigation page is hosted on the same server then you can prevent the "insecure content" message by using a relative URL like this...

<iframe src="/app/navigation.jsp" />

从您的问题来看,您的导航页面似乎是由单独的主机提供的,而您***使用类似的内容

From your question it sounds like your navigation page is being served from a separate host and you're being forced to use something like this

<iframe src="http://otherserver.example.com/app/navigation.jsp" />

这当然会导致浏览器中出现内容不安全"消息.

which will of course cause the "insecure content" message in your browser.

你唯一的解决办法是要么

Your only solutions are to either

  1. 在保存导航页面的服务器上实施 SSL,以便您可以使用 https:// 作为 iframe 引用,或

  1. implement SSL on the server holding your navigation page so you can use https:// for your iframe reference, or

将导航应用程序移至同一服务器,以便您可以使用相对 URL.

move the navigation application to the same server so you can use a relative URL.

我个人不明白为什么你的导航会在不同的主机上,因为那样你会遇到 JavaScript 跨域脚本问题(除非涉及一些时髦的 JSONP).

Personally I can't see why your navigation would be on a different host because then you're going to get JavaScript cross-domain scripting issues (unless some funky JSONP is involved).