Update: Matthew Wise has a really smart alternative solution that you should consider, especially if you have problems with my approach or you don't like ugly hacks!
There is a way to cover window elements in IE with other elements, but you won't like it.
Background: window and windowless elements
In obsolete IE, elements are divided into two types: window and windowless.
Regular elements such as div and input have windows . They are displayed by the browser itself in the same MSHTML plane and correspond to each other in z-order.
Elements displayed outside of MSHTML are windowed ; for example, select (OS is displayed) and ActiveX controls. They respect each other in z-order, but occupy a separate MSHTML plane, which is drawn on top of all windowless elements.
The only exception is iframe . In IE 5, an iframe was a window element. This has been changed in IE 5.5 ; it is now a windowless element, but for backward compatibility reasons it will still draw over window elements with a lower z-index
In other words: the iframe takes into account the z-index for both window and windowless elements . If you are an iframe on a window element, all windowless elements located above the iframe will be visible!
What does it mean
PDF will always be drawn on top of regular page content - as select elements prior to IE 7 . The fix is ββto place another iframe between your content and the PDF.
demonstration
jsFiddle: http://jsfiddle.net/Jordan/gDuCE/
The code
HTML:
<div id="outer"> <div id="inner">my text that should be on top</div> <iframe class="cover" src="about:blank"></iframe> </div> <iframe id="pdf" src="http://legallo1.free.fr/french/CV_JLG.pdf" width="200" height="200"></iframe>
CSS:
#outer { position: relative; left: 150px; top: 20px; width: 100px; z-index: 2; } #inner { background: red; } .cover { border: none; position: absolute; top: 0; left: 0; height: 100%; width: 100%; z-index: -1; } #pdf { position: relative; z-index: 1; }
Support
This has been tested and should work in IE 7β9. If you feel finicky about its appearance in the DOM for other browsers, you can add it using JavaScript or wrap it in a conditional comment only for IE:
Jordan Gray Oct 19 '12 at 15:07 2012-10-19 15:07
source share