我的 Greasemonkey 脚本损害了 IE9 HTTPS 安全性?
我在 IE9 中有一个导入 jQuery 的 Greasemonkey-for-IE 脚本。但在安全页面上它不起作用。
我得到:
SEC7111: HTTPS security is compromised by http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
失败的代码是:
var script = document.createElement("script");
script.setAttribute("src",
"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js");
我怎样才能使它工作?该脚本不会在 Firefox 中引起问题。
I’ve got a Greasemonkey-for-IE script in IE9 that’s importing jQuery. But on secure pages it doesn’t work.
I’m getting:
SEC7111: HTTPS security is compromised by http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
The code that fails is:
var script = document.createElement("script");
script.setAttribute("src",
"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js");
How can I make this work? The script doesn’t cause a problem in Firefox.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以通过使用与方案相关的 URL,通过更简单的代码来消除该问题,如下所示:
这将在
http://
页面上使用http://
,并且https://
在https://
页面上...解决问题的更简单方法。You can eliminate the issue with simpler code by using a scheme-relative URL like this:
This will use
http://
on anhttp://
page andhttps://
on anhttps://
page...a much simpler way to solve the issue.大概:使用 https://ajax.googleapis.com/ ajax/libs/jquery/1.4.2/jquery.min.js 改为(或不信任第三方 CDN(既值得信赖又不会受到损害)的安全页面)
Presumably: Use https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js instead (or not trust a third party CDN (to be both trustworthy and not compromised) for your secure pages)
该错误消息是 IE 针对混合内容(安全页面上的 HTTP 和 HTTPS 资源)发出警告的新方式。 此处 是相关的 MSDN 博客文章。
使用
似乎也有效,尽管我在 库 API 概述。
The error message is IE's new way of warning about mixed content (HTTP and HTTPS resources on a secure page). Here is a related MSDN blog post.
Using
seems to work as well, although I can't see a official reference to it in the Libraries API overview.
问题是,当您处于安全模式(即 HTTPS)时,页面加载的所有文件也必须是 HTTPS。您在这里制作的 JQuery 包含是 HTTP。
您需要检测页面是处于 HTTP 还是 HTTPS 模式(使用
window.location.protocol()
),并调整 JQuery include 的 URL 以适应。 (它所需要的只是“http”后面附加的“s”)The problem is that when you're in secure mode (ie HTTPS), all the files loaded by the page must also be HTTPS. The JQuery include you're making here is HTTP.
You need to detect whether the page is in HTTP or HTTPS mode (use
window.location.protocol()
), and adjust the URL of the JQuery include to suit. (all it needs is the additional 's' after 'http')您正在使用 https 连接并且想要访问 http 连接。
you are using https connection and you want to access a http connection.