Javascript 我的 Greasemonkey 脚本破坏了 IE9 HTTPS 安全性?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3905840/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
IE9 HTTPS security is compromised by my Greasemonkey script?
提问by heffaklump
I've got a Greasemonkey-for-IEscript in IE9 that's importing jQuery. But on secure pages it doesn't work.
我在 IE9 中有一个用于导入 jQuery的Greasemonkey-for-IE脚本。但是在安全页面上它不起作用。
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.
我怎样才能使这项工作?该脚本不会在 Firefox 中引起问题。
回答by Nick Craver
You can eliminate the issue with simpler code by using a scheme-relative URL like this:
您可以通过使用类似这样的方案相对 URL 用更简单的代码来消除这个问题:
var script = document.createElement("script");
script.setAttribute("src",
"//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js");
This will use http://
on an http://
page and https://
on an https://
page...a much simpler way to solve the issue.
这将http://
在一个http://
页面和一个页面https://
上使用https://
......解决问题的更简单的方法。
回答by Quentin
Presumably: Use https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.jsinstead (or not trust a third party CDN (to be both trustworthy and not compromised) for your secure pages)
大概:为您的安全页面使用https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js(或不信任第三方 CDN(既值得信赖又不受损害) )
回答by Pekka
The error message is IE's new way of warning about mixed content (HTTP and HTTPS resources on a secure page). Hereis a related MSDN blog post.
该错误消息是 IE 对混合内容(安全页面上的 HTTP 和 HTTPS 资源)发出警告的新方式。这是一篇相关的 MSDN 博客文章。
Using
使用
https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js
seems to work as well, although I can't see a official reference to it in the Libraries API overview.
回答by Spudley
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.
问题在于,当您处于安全模式(即 HTTPS)时,页面加载的所有文件也必须是 HTTPS。您在此处创建的 JQuery 包括 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')
您需要检测页面是处于 HTTP 模式还是 HTTPS 模式(使用window.location.protocol()
),并调整 JQuery 包含的 URL 以适应。(它所需要的只是'http'之后的附加's')
回答by Erhard Dinhobl
you are using https connection and you want to access a http connection.
您正在使用 https 连接并且想要访问 http 连接。