Javascript “iFrame重叠jQuery”对话框中的PDF,z索引不起作用
我尝试了许多选项来修复PDF iFrame重叠jQuery对话框的z索引问题,但仍然不起作用 与"发行"类似,, 我在IE中也有同样的问题,以下是我问题的截图: 下面是生成对话框的jQuery代码:-Javascript “iFrame重叠jQuery”对话框中的PDF,z索引不起作用,javascript,jquery,pdf,iframe,z-index,Javascript,Jquery,Pdf,Iframe,Z Index,我尝试了许多选项来修复PDF iFrame重叠jQuery对话框的z索引问题,但仍然不起作用 与"发行"类似,, 我在IE中也有同样的问题,以下是我问题的截图: 下面是生成对话框的jQuery代码:- $("#cancelSessionButton").click(function () { $("#sessionReason").dialog("open"); $("#pdf").hide();
$("#cancelSessionButton").click(function () {
$("#sessionReason").dialog("open");
$("#pdf").hide();
});
$("#sessionReason").dialog({
autoOpen: false,
modal: true,
buttons: {
"Submit": function () {
.......
},
"Cancel": function () {
$(this).dialog("close");
$("#pdf").show();
}
}
});
$("#cancelSessionButton").click(function () {
$("#sessionReason").dialog("open");
$("#pdf").hide();
});
以下是生成iFrame的HTML:
<div id="pdf">
<iframe id="pdfIframe" name="pdfIframe" src="pdf.html" style="width: 100%; height: 100%;" scrolling="auto" frameborder="1">
Your browser doesn't support inline frames.
</iframe>
</div>
您的浏览器不支持内嵌框架。
PDF.html代码:
<body>
<object data="lorem.pdf" type="application/pdf">
<p>It appears you don't have Adobe Reader or PDF support in this web browser.
<br/>
<a href="lorem.pdf">Click here to download the PDF</a> OR <a href="http://get.adobe.com/reader/" target="_blank">Click here to install Adobe Reader</a></p>
<embed id="pdfDocument" src="lorem.pdf" type="application/pdf" />
</object>
</body>
此web浏览器中似乎不支持Adobe Reader或PDF。
或
如果您需要任何其他信息,请告诉我
请建议 有一个解决方案是使用iframe hack(请参见此问题了解该hack的解释:) 从jQuery1.9开始,您可以扩展JQuery
ui.dialog
组件。解决方案是向.ui对话框
DOM元素添加一个iframe
。您可以这样做:
$.widget( "ui.dialog", $.ui.dialog, {
_parentInit: $.ui.dialog.prototype._init,
_init: function() {
this._parentInit();
$("<iframe src=\"about:blank\" frameborder=\"0\" style=\"position:absolute; top:0;left:0; width:100%;height:100%;z-index:-1;\"></iframe>").appendTo(this.element.parent());
}
});
$.widget(“ui.dialog”,$.ui.dialog{
_parentInit:$.ui.dialog.prototype.\u init,
_init:function(){
这个;
$(“”).appendTo(this.element.parent());
}
});
必须在初始化任何对话框之前执行Javascript代码。这意味着,它应该位于头部
部分,而不应该等待DOM就绪
每个JQuery对话框都会自动添加
iframe
,这解决了IE中Adobe插件的分层问题。我用IE11测试了该解决方案。我不确定是否可以在IE中的PDF查看器上显示一个简单的div,不过,也许你可以做一些变通(就像在显示对话框时隐藏pdf查看器)。作为替代方法,我只会这样做…根据对话框的打开和关闭显示和隐藏pdf我想这是解决此问题的最简单方法。是的…但仍然想检查是否有任何解决方案…以防我的解决方案不可接受..你看;-)我明白了。这里介绍了一种解决方法:,但它更适合于屏蔽pdf,而不是在上面显示某些内容。