隨筆 - 81  文章 - 1033  trackbacks - 0
          <2007年4月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          在浮躁的年代里,我們進取心太切,患得患失;虛榮心太強,戰戰兢兢。一心爭強好勝,惟恐榜上無名。
          I think I can fly , and flying like a bird !
          程序員一名,已售出,缺貨中!

          我的郵件聯系方式

          用且僅用于MSN

          博客點擊率
          free web counter
          free web counter

          常用鏈接

          留言簿(36)

          隨筆檔案

          搜索

          •  

          積分與排名

          • 積分 - 187324
          • 排名 - 309

          最新評論

          閱讀排行榜

          評論排行榜

          ??????只能說IE有太多臭名昭著的BUG,讓我頭疼不已。數本關于頁面標準的經典大作上也毫不留情的把IE批的一錢不值,我想大師們也是痛恨的。下拉框可以說是最著名的之一,不知道為啥它總要在最上面,匪夷所思。我一般的做法是需要的時候直接把頁面內所有select全visibility:hidden了,注意在這里display:none是個很危險的操作,至于為什么大家自己琢磨它們的區別吧。

          ??????最近一個朋友做個menu必須要覆蓋select,沒辦法只有用下面這個方法。

          轉載自:http://dotnetjunkies.com/WebLog/jking/archive/2003/07/21/488.aspx

          It was about 1 year ago that Coalesys released the first WebMenu 2.0 beta.? At that time we began demonstrating a technique for overlaying windowed controls in Internet Explorer.

          In case you don't already know, windowed controls in IE will always cover DHTML layers.? That means if you have a DIV that pops up or floats on the page and it intersects with a windowed control (such as the common SELECT box), the windowed control will obscure the DIV, no matter what zIndex you have set for each element.? More information is available in this Microsoft KB article.

          The initial solution adopted by most developers who cared about such things (including ourselves) was to dynamically hide windowed controls when it was necessary to display the DIV over them.? Far from being a perfect solution, it was better than the alternative of doing nothing at all.

          It did have one very frustrating aspect.? People who evaluated WebMenu didn't understand why their select boxes would disappear.? And we are talking much more than just ASP.NET developers, as we produce WebMenu for ASP, as well as general web development.? It seemed like every day we received a support question, "I found a bug in WebMenu.?The select boxes are disappearing".? And although we did provide the ability to turn the feature off, nobody really bothered once they understood the nature of the issue.

          Then, as luck would have it, a developer called who wanted to use our product for it's broad set of features, but who absolutely needed to have the menu appear over some windowed objects.? What was unique about his call was that he had the idea for a solution and shared it with us.? While we didn't use the full scope of his idea, we were able to take from it what we needed to cover windowed controls in IE 5.5.??So, enough yacking.? You probably surfed here to read about the solution.? And here it is:

          IFRAME

          The IFRAME control has a unique nature in IE 5.5.? It can exist in both the zIndex of windowed controls and the zIndex of regular HTML elements.? Simply put, you can shim an IFRAME under your DIV.?The IFRAME will block out the windowed control.

          Set up your IFRAME:

          <IFRAME style="DISPLAY: none; LEFT: 0px; POSITION: absolute; TOP: 0px" src="javascript:false;" frameBorder="0" scrolling="no"></IFRAME>

          The src attribute is set?with a useless JavaScript statement so that the IFRAME does not try to load a page (which you won't notice it doing, but it will be the cause for tripping the "Unsecured Items" message if you use it on a HTTPS page).

          You can code your IFRAME as a static element on the page, or if you are going to be using more than one of them you may want to dynamically create them as required.? The insertAdjacentHTML() method is good for that.

          Now, all that is needed is to size the IFRAME according to the dimensions of your DIV, position it,?place it one layer beneath the DIV in the zIndex order and make it "visible".? The IFRAME's style object will allow you to do these tasks:

          iframe.style.top
          iframe.style.left
          iframe.style.width
          iframe.style.height
          iframe.style.zIndex
          iframe.style.display

          What about?transparency?

          If the DIV has transparent areas, you'll want those areas?to punch?through the IFRAME to the page background.? There are two ways you can make an IFRAME transparent.? The one that works for this situation is to set the style object's filter property:

          iframe.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';

          This in effect makes the entire IFRAME transparent, but it will still block out the windowed controls.? The other technique, which uses?the IFRAME element's ALLOWTRANSPARENCY attribute, actually pertains to making the?interior page background of the IFRAME transparent, so that any?content inside the IFRAME?can have transparency.? However, this mode changes the nature of the IFRAME and it no longer serves our purpose for blocking out windowed controls.

          What about IE versions prior to 5.5?

          The IFRAME's unique nature surfaced only in IE 5.5.? Prior to this, IFRAMEs where straight windowed controls themselves.? That means they could get above?other windowed controls, but no HTML element (like the DIV) could be seen above them.? There is a solution, but it involves a lot of effort to get working.? You can dynamically write the content of your DIV into the IFRAME itself, get it sized appropriately based on the dimensions of the original DIV, and then just move it around as your absolutely positioned element.? There are a couple of caveats:

          1.? The IFRAME, like any?frame, ?has it's own JavaScript environment.? If you want DHTML actions in the IFRAME to integrate with the JavaScript functions in your main page, you will have to bridge the gap between the two JavaScript environments.

          2.? Mouse events, such as OnMouseOut and OnMouseOver, can be called out of logical order when the mouse moves between frames in IE 4 and 5.? This problem is compounded when you are using timers and need to precisely control their execution and cancellation via mouse events.

          Our original WebMenu 2.0 beta used this technique successfully for IE 4 and 5, but in?looking forward to adding new features to the product, we could see that this solution "over-worked the plumbing" to a great extent.? The "shim" technique?compatible only with IE 5.5 had zero architectural impact and was chosen for this reason.? You can still hide windowed elements in earlier browsers as an acceptable solution.


          ??????還有一篇中文的,在google里很多,我也不知道哪個是原作,如果是您,請通知我我會立即加上鏈接:)

          下拉框,即html的SELECT元素,.net設計時的DropDownList,是html中的windowed element,尤其ie6之后,幾乎是唯一的windowed element(還有popup等少量極少用的的)。

          普通的元素,textbox, div, table……這些,屬于windowless element,它們之間互相遮蓋的情況由z-index決定,在它們之上,是SELECT這些windowed element。所以一般情況下div、table等不能遮蓋select。

          這個問題廣泛存在于各種彈出式控件的使用之中,比如日歷控件等。

          如果要顯示div,以前的做法是,動態的,在顯示的時候,讓div區域的select不可見,div消失的時候,再恢復這些select元素。這種做法比較奇怪,因為它嚴格上并不是“遮蓋”了select,而是,讓她整個消失了,如果calendar彈出元素只是應該遮蓋select元素的一部分,但select卻整個不見,用戶也許會覺得奇怪;做起來也麻煩,要用js逐一判斷各select的位置。

          ie5.5之后,有一個新的小技巧,稱之為“iframe shim”(iframe加塞:p),可以真正的“遮蓋”select元素。

          它利用了一種特殊的元素:iframe。在ie5.5之前,iframe也是windowed element,但從5.5開始,iframe就是普通的windowless element了,可是,雖然是windowless element,iframe卻可以蓋住select。這種做法的原理就是:放一個iframe與你要顯示的東西(比如說一個div)同樣大小、位置,并設置z-index使得iframe在此DIV之下;這樣,iframe遮蓋了select,同時,iframe又在要顯示的div的下面,div就露出來了。

          限制:僅適用于ie5.5及以后版本。

          參考文章鏈接:
          http://dotnetjunkies.com/WebLog/jking/archive/2003/07/21/488.aspx

          示例程序代碼:
          //html.select.hack.iframe shim.htm
          <html>
          <head>
          <script>
          function DivSetVisible(state)
          {
          var DivRef = document.getElementById('PopupDiv');
          var IfrRef = document.getElementById('DivShim');
          if(state)
          {
          DivRef.style.display = "block";
          IfrRef.style.width = DivRef.offsetWidth;
          IfrRef.style.height = DivRef.offsetHeight;
          IfrRef.style.top = DivRef.style.top;
          IfrRef.style.left = DivRef.style.left;
          IfrRef.style.zIndex = DivRef.style.zIndex - 1;
          IfrRef.style.display = "block";
          }
          else
          {
          DivRef.style.display = "none";
          IfrRef.style.display = "none";
          }
          }
          </script>
          </head>
          <body background="http://www.orkut.com/img/i_blau2.gif">
          <form>
          <select>
          <option>A Select Box is Born ....</option>
          </select>
          </form>
          <div
          id="PopupDiv"
          style="position:absolute;font:italic normal bolder 12pt Arial; top:25px; left:50px; padding:4px; display:none; color:#ffff00; z-index:100">
          .... and a DIV can cover it up<br>through the help of an IFRAME.
          </div>
          <iframe
          id="DivShim"
          src="javascript:false;"
          scrolling="no"
          frameborder="0"
          style="position:absolute; top:0px; left:0px; display:none;filter=progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0);">
          </iframe>
          <br>
          <br>
          <a href="#" onclick="DivSetVisible(true)">Click to show DIV.</a>
          <br>
          <br>
          <a href="#" onclick="DivSetVisible(false)">Click to hide DIV.</a>
          </body>
          </html>

          posted on 2007-04-01 17:52 cresposhi 閱讀(2786) 評論(11)  編輯  收藏

          FeedBack:
          # re: How to cover an IE windowed control (Select Box, ActiveX Object, etc.) with a DHTML layer. 【轉載】 2007-04-12 12:00 砸碎單份
          看不懂,句子不通順,不如英文原文清楚  回復  更多評論
            
          # re: How to cover an IE windowed control (Select Box, ActiveX Object, etc.) with a DHTML layer. 【轉載】 2007-04-12 12:03 cresposhi
          @砸碎單份
          啊。。。我這個就是轉載的英文原文啊  回復  更多評論
            
          # re: How to cover an IE windowed control (Select Box, ActiveX Object, etc.) with a DHTML layer. 【轉載】 2007-04-30 00:01 Iwishyou2
          好了,現在的IE7出來了, 修復了這個bug。 不過我平時上網實在很少用IE, 除了公司寫代碼測試的時候要用IE, 一個因為他不安全, 老是帶來各種病毒或者流氓軟件, 二是它速度卻是不敢恭維 。。。。。。  回復  更多評論
            
          # re: How to cover an IE windowed control (Select Box, ActiveX Object, etc.) with a DHTML layer. 【轉載】 2007-04-30 23:45 cresposhi
          呵呵,但是用戶應該還是IE居多吧,可能現在用IE6,IE7的都比較多,以前最主要考慮IE和FF,現在又來個IE7,又加大了開發的成本,哎  回復  更多評論
            
          # re: How to cover an IE windowed control (Select Box, ActiveX Object, etc.) with a DHTML layer. 【轉載】 2011-09-02 16:56 credit loans
          The home loans seem to be essential for guys, which would like to start their own career. By the way, that's not hard to receive a student loan.   回復  更多評論
            
          # re: How to cover an IE windowed control (Select Box, ActiveX Object, etc.) with a DHTML layer. 【轉載】 2012-02-23 14:56 essay writing services
          High school students don't want to see frauds! People request premium quality essay writing services that can be online 24/7. Moreover, uncommon projects are required.   回復  更多評論
            
          # re: How to cover an IE windowed control (Select Box, ActiveX Object, etc.) with a DHTML layer. 【轉載】 2012-02-23 14:58 custom research writing
          Difficult academic papers writing can be not a trouble for modern students. Just because custom writing essay company will soleve any academic complications.   回復  更多評論
            
          # re: How to cover an IE windowed control (Select Box, ActiveX Object, etc.) with a DHTML layer. 【轉載】 2012-02-29 20:08 quality directory submission services
          To earn cash in the web, your product pages need to be detected in a group of top results for specific keywords and products. To get there, you need the most experienced directory submissions services and link building stuff. Experts are able to turn visitors into customers.   回復  更多評論
            

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 买车| 石家庄市| 简阳市| 涟水县| 昭平县| 砀山县| 玛多县| 北流市| 清苑县| 峨山| 伊春市| 夏津县| 西乌| 灵石县| 二连浩特市| 神池县| 额济纳旗| 肇源县| 武清区| 洞头县| 广宗县| 乐都县| 蒲城县| 新龙县| 梅河口市| 汪清县| 临夏县| 崇信县| 道真| 濮阳县| 青州市| 东乡族自治县| 水城县| 台南县| 临沭县| 文登市| 那曲县| 巨鹿县| 大同市| 龙泉市| 姜堰市|