2012年3月2日 星期五

解決IE6 Select 與 z-index 的問題

解決IE6 Select 與 z-index 的問題: 看來只能透過 iframe 去處理啦~ <html> <head> <script type="text/javascript"> // make the specified div a windowed control in IE6 // this masks an iframe (which is a windowed control) onto the div, // turning the div into a windowed control itself function makeWindowed(p_div) { var is_ie6 = document.all && (navigator.userAgent.toLowerCase().indexOf("msie 6.") != -1); if (is_ie6) { var html = "<iframe style=\"position: absolute; display: block; " + "z-index: -1; width: 100%; height: 100%; top: 0; left: 0;" + "filter: mask(); background-color: #ffffff; \"></iframe>"; if (p_div) p_div.innerHTML += html; // force refresh of div var olddisplay = p_div.style.display; p_div.style.display = 'none'; p_div.style.display = olddisplay; }; } </script> </head> <body> <div id="test" style="position: absolute; z-index: 2; top: 50; left: 30; width: 200px; height: 200px; background-color: red"> &nbsp; </div> <select style="position: absolute; z-index: 1; top: 50;"> <option>test</option> </select> <a href="javascript:makeWindowed(document.getElementById('test'));"> Make Windowed</a> </body> </html>

【下列文章您可能也有興趣】

沒有留言: