简体   繁体   English

Chrome的Javascript / JQuery事件阻止了不安全的内容

[英]Javascript/JQuery event for Chrome blocking insecure content

If a page is served over https but the associated files are served from a non-secure http website, Chrome will throw the “insecure content” warning. 如果网页是通过https提供的,但是相关文件是从不安全的http网站提供的,则Chrome会抛出“不安全的内容”警告。 Is there an event/property that I could be using to know when Chrome has blocked an unsecure content and also know if the user allowed the insecure content. 是否可以使用某个事件/属性来了解Chrome何时阻止了不安全的内容,并且还知道用户是否允许不安全的内容。 A shield appears at the right of the adress bar when Chrome loads "insecure content" and the user has the possibility to click on this shield and still run the script. 当Chrome加载“不安全内容”时,地址栏右侧会出现一个防护罩,用户可以单击该防护罩并仍然运行脚本。 Is there any event for this? 有什么事吗?

Thank you. 谢谢。

The only way I can think to do this would be to serve a file over non-https, that would include a function to run if they allow non-secure content. 我能想到的唯一方法是在非https上提供文件,如果允许非安全内容,该文件将包含一个要运行的功能。

This script will obviously only be included if they've allowed the non-secure content to be loaded, and therefore works as your event check. 显然,只有在允许加载非安全内容的情况下才包含此脚本,因此可以用作事件检查。 You can therefore also check if these haven't been allowed by storing a global variable in the non-secure file & checking for it in a secure JS file (or within the document). 因此,你也可以检查,如果这些都没有被允许在非安全文件存储的全局变量和在一个安全的JS文件检查它(或文档中)。

Obviously, if you're serving content via SSL, you should really ensure all of your content included is also over SSL. 显然,如果您通过SSL提供内容,则应确保所有包含的内容也都通过SSL进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM