简体   繁体   English

使用JavaScript或jQuery检测Firefox混合内容阻止?

[英]Detect Firefox mixed content blocking with JavaScript or jQuery?

How do I detect Firefox's (or any browser's) mixed content blocking "feature" with JavaScript or jQuery? 我如何检测Firefox(或任何浏览器)的混合内容阻止JavaScript或jQuery的“功能”?

More about Firefox's mixed content blocking: https://blog.mozilla.org/tanvi/2013/04/10/mixed-content-blocking-enabled-in-firefox-23/ 有关Firefox混合内容阻止的更多信息: https//blog.mozilla.org/tanvi/2013/04/10/mixed-content-blocking-enabled-in-firefox-23/

The long story: 长话说:

My company has a vendor that provides the online ordering part of our website. 我公司的供应商提供了我们网站的在线订购部分。 The online ordering is using https while our main website is using http. 在线订购使用https,而我们的主要网站使用http。 I was asked to restyle the vendor's online ordering pages to match the look and feel of our main site. 我被要求重新设置供应商的在线订购页面的样式,以匹配我们主站点的外观。 Our vendor's online ordering pages have two iframes, one for the header and one for the footer. 我们供应商的在线订购页面有两个iframe,一个用于页眉,一个用于页脚。 I updated the navigation links in the header and footer with target="_parent" and that works in all browsers except Firefox 23 because FF23 is blocking the links that point to http sources. 我用target =“ _ parent”更新了页眉和页脚中的导航链接,该链接在Firefox 23以外的所有浏览器中都可以使用,因为FF23阻止了指向http源的链接。 My plan was to simply write a script to change the link target="_blank" and let Firefox users get pop-up windows instead. 我的计划是简单地编写一个脚本来更改链接target =“ _ blank”,然后让Firefox用户获得弹出窗口。 But now jQuery has removed the "jQuery.browser" feature in version 1.9 and says to try and use feature detection instead. 但是现在jQuery在1.9版中删除了“ jQuery.browser”功能,并表示尝试使用功能检测。 So after a while googling I come here to humbly ask this question. 所以过了一会儿谷歌搜索后,我来到这里谦虚地问这个问题。 Yes, I know I can just write plain JavaScript to detect browsers but I figure using feature detection in this case would be better. 是的,我知道我可以编写普通的JavaScript来检测浏览器,但是我认为在这种情况下使用功能检测会更好。

You are mistaken as to the scope of mixed content blocking - it is present in virtually all current browsers, including: 您将混合内容阻止的范围弄错了-它几乎存在于当前所有浏览器中,包括:

You will need to restructure your site such that it does not load mixed content. 您将需要重组您的网站,以使其不加载混合内容。 In this case, this will probably require that you make your main website available over HTTPS. 在这种情况下,这可能需要您通过HTTPS使您的主要网站可用。

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

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