我正在开发一个Facebook应用程序,它结合了我们的Brightcove (视频主机)播放器和他们的API。Facebook为用户提供了安全浏览的选择,这给用户带来了一点问题。目前,我可以让应用程序在其中一个协议(http或https)上正常工作,但不能两者兼而有之。
https://www.facebook.com/atlantafalcons?sk=app_292392080815275 (更改为http://以查看它不起作用)
如果我将BrightcoveExperiences.js文件源设置为https://sadmin.brightcove.com/js/BrightcoveExperiences.js,那么当有人没有安全浏览时,它会抛出错误。如果我将其设置为http://admin.brightcove.com/js/BrightcoveExperiences.js,那么当有人安全地浏览时,它会抛出错误。
用于安全嵌入的文档如下:http://support.brightcove.com/en/docs/publishing-brightcove-player-https-page
是否有一种方法可以检测用户是否正在安全地浏览以便能够选择要加载哪个JS文件,还是有一种强制用户安全浏览的方法?或者,对于这样的问题,还有别的解决办法吗?
提前感谢!
编辑:想出了一个解决方案(感谢scibuff推荐查看google ):
<script type="text/javascript">
var bJsHost = (("https:" == document.location.protocol ) ? "https://sadmin." : "http://admin.");
document.write(unescape("%3Cscript src='" + bJsHost + "brightcove.com/js/BrightcoveExperiences.js' type='text/javascript'%3E%3C/script%3E"));
</script>发布于 2012-03-02 16:56:35
使用方案-相对URI:
//admin.brightcove.com/js/BrightcoveExperiences.js也不要对SSL和非SSL实例使用不同的主机名。
(或者让sadmin对非SSL请求使用301重定向到admin )
发布于 2012-03-02 16:56:12
我同意昆汀的建议。尽管,使用您的建议,您可以使用:
// window, top, self, document, others?
window.location.protocol换言之:
if (window.location.protocol == 'http:') {
document.body.innerHTML = 'The page is using the http (non-secure) protocol.';
} else {
document.body.innerHTML = 'The page is using the https (secure) protocol.';
}http://jsfiddle.net/3NREg/
其他窗口/文档对象也可以工作,这取决于您需要什么:
// window, top, self, document, others?
if (self.location.protocol == 'http:') {
document.body.innerHTML = 'The page is using the http (non-secure) protocol.';
} else {
document.body.innerHTML = 'The page is using the https (secure) protocol.';
}http://jsfiddle.net/3NREg/1/
https://stackoverflow.com/questions/9537195
复制相似问题