How to keep dropdown menu on top of ActiveX

回眸只為那壹抹淺笑 提交于 2019-12-10 19:32:44

问题


I have a drop-down menu created by JavaScript on all pages and some columns have up to 20 items. This drop-down appears topmost over all content in Mozilla browsers but in Internet Explorer it gets partially covered when an ActiveX object is displayed just below it.

I have tried displaying the ActiveX in a DIV layer and setting z-index but so far I haven't found a solution that works. Adding style to the object tag had no effect...

<object etc style='z-index:3;'>

Applying style to a DIV containing the object also had no effect...

<div align="center" style="z-index:2;">

The dropdown menu has a z-index=1 applied. Adding a 'wmode' parameter to the object also did not work...

<param name='wmode' value='transparent'>

回答1:


Apparently the issue is in-process vs out-of-process plugins. In-process plugins (and activex) will run in the same environment as the web page itself and honour z-ordering. But in-process is rare. Most browsers run plugins and activex in a separate process, so the web page is in one process and the activex/plugin is in a different process. The browser makes it APPEAR like it’s a single process by causing the plugin/activex to DRAW itself in the screen area containing the web page, but you understand its smoke and mirrors and z-ordering is practically ignored. It draws the web page (including menus) and THEN it causes the plugin/activex to draw.

The only way around it (and doesn’t always work) is to wrap the html menu in an iframe.




回答2:


I wanted to expand on the issue here. The answer provided by WilliamK is kind of in the right direction but doesn't really explain the real cause of the problem nor does he provide an adequate solution.

The main cause of the problem is the fact that some UI elements are rendered in a windowed context (vs. windowless) which basically means that it's rendered in a separate OS-level process which takes place on top of the browser and not within the browser. This follows what WilliamK was trying to explain, except browsers these days are multithreaded so "out-of-process" doesn't tell the whole story. Here's a great explanation of windowed vs. windowless.

An easy solution to this is not to render something within an iframe, but to have an iframe sitting behind any content you want rendered on top of another windowed object. This is best explained by example. Assume that the <object> is some ActiveX or Flash object rendered in its own windowed context:

<style>
.overlay {
    position: absolute;

    /* adjust for your site - values shown here are arbitrary */
    width: 600px;
    height: 600px;
    top: 100px;
    left: 100px;
    z-index: 1;
    overflow: auto;
}

.overlay-content {
    position: relative;
    z-index: 2;
}

.overlay iframe {
    position: absolute;
    z-index: 1;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}
</style>

<body>
    <object ...></object>
    <div class="overlay">
        <div class="overlay-content">This is content you want to appear on top of the windowed object</div>
        <iframe border="0"></iframe>
    </div>
</body>


来源:https://stackoverflow.com/questions/14063405/how-to-keep-dropdown-menu-on-top-of-activex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!