X-Frame-Options拒绝加载:colorbox无法在iframe

时间:2015-10-06 07:00:04

标签: javascript java jquery iframe colorbox

将PDF打开到colorbox iframe时遇到问题。这是我到目前为止所做的方法..

在FileInputStream中读取文件并将其写入OutputStream。

Java Code Snippet ..

            response.setContentType(imageContentType);
            OutputStream out = response.getOutputStream();
            FileInputStream fis = new FileInputStream(file);
            byte[] buf = new byte[4096];
            int len = -1;
            while ((len = fis.read(buf)) != -1) {
                out.write(buf, 0, len);
            }
            out.flush();
            out.close();

JSP ..

<a class='cboxPDF imguid cboxElement' href='/view/B2BSpineShippingAndPaymentComponentController?showHCPOFile=true&attachmentLocation=XXXX.pdf' />

JS ..

$(".cboxPDF").colorbox({
                    scrolling:  false,
                    iframe:true,
                    innerWidth:725,
                    innerHeight:545,
                    overlayClose: false,
                    onOpen: function(){
                        $("#colorbox").css("opacity", 0);
                        $(".page-loaderOverlay").show();
                    },
                    onComplete: function(){
                        $(".overlay").show();
                        $(".page-loaderOverlay").hide();
                        $("#colorbox").css("opacity", 1);
                    }               
                });

以上代码在我的本地服务器上正常运行。我可以在colorbox iframe上传和检查附加的PDF。

但是在主机服务器上,它无法正常工作。 Firebug正在显示此异常

Load denied by X-Frame-Options: https://b2bssit.myorders.medtronic.com/view/B2BSpineShippingAndPaymentComponentController?showHCPOFile=true&attachmentLocation=PO_S002_S10000277003_1.pdf does not permit framing.

我脑子里有几件事情在发生。

  1. 这是一个Infra团队问题(在此环境中在IFrame中打开PDF的安全性)
  2. 错误的X-Frame-Option。 (我们已经设置了<meta http-equiv="X-Frame-Options" content="SAMEORIGIN">
  3. 缺少彩盒选项。
  4. 我无法理解为什么它在本地工作但不在主机服务器上工作。

    请帮忙。

0 个答案:

没有答案
相关问题