div不能放在applet上的解决方案(iframe)

    今天尝试着把worldwind放在底层,然后上面浮动div,结果发现applet的层级实在是太高了,网上的解决方案是用flash或者object。

     给大家看个iframe的解决办法,是国外的一个程序员做的http://www.oratransplant.nl/2007/10/26/using-iframe-shim-to-partly-cover-a-java-applet/

 

 
    效果是将sub div放在了一个applet时钟上,实际上是sub iframe。
 
HTML:
<!DOCTYPE html PUBLIC
   "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
  <body>
    <script type="text/javascript">
      function mouseIn() {
        // create an iframe at the exact same position and
        // size as the sub div
        // Google "iframe shime" for more information
        var shimmer = document.createElement('iframe');
        shimmer.id='shimmer';
        shimmer.style.position='absolute';
        // normally you would get the dimensions and
        // positions of the sub div dynamically. For demo
        // purposes this is hardcoded
        shimmer.style.width='150px';
        shimmer.style.height='80px';
        shimmer.style.top='100px';
        shimmer.style.left='80px';
        shimmer.style.zIndex='999';
        shimmer.setAttribute('frameborder','0');
        shimmer.setAttribute('src','javascript:false;');
        document.body.appendChild(shimmer);
        // make sub div visible
        var sd = document.getElementById('subdiv');
        sd.style.visibility='visible';
      }
      function mouseOut() {
        var sd = document.getElementById('subdiv');
        sd.style.visibility='hidden';
        var shimmer = document.getElementById('shimmer');
        document.body.removeChild(shimmer);
      }
    </script>
    <style type="text/css">
      #maindiv {display:block; width:150px; height:80px;
                background:red;}
      #subdiv  {display:block; width:150px; height:80px;
                background:blue; position:absolute;
                top:100px; left:80px;
                z-index:1000; visibility:hidden;}
    </style>
    <!-- top level div -->
    <div id="maindiv" onmouseover="mouseIn();"
                        onmouseout="mouseOut();">

      <p>MAIN DIV </p>
      <p>move mouse here </p>
    </div>
    <!-- subdiv that gets shown when mouse hovers
         over top level div -->

    <div id="subdiv">
      <p>SUB DIV </p>
    </div>
    <!-- java applet -->
    <applet style"border:1px solid blue;"
            codebase="http://java.sun.com/applets/jdk/1.4/demo/applets/Clock/"
            code="Clock.class" width="170" height="150">

    </applet>
  </body>
</html>
 
     后来又有个家伙做了一个导航菜单,个人觉得还是很值得看下的。
  1.     Ext.onReady(function(){  
  2.         var tb = Ext.getCmp('inventory');  
  3.         tb.on('menushow',function(toolbar,menu) {  
  4.             var menuEl = menu.getEl();  
  5.             createShim({  
  6.                 top:menuEl.getY(),  
  7.                 left:menuEl.getX(),  
  8.                 width:menuEl.getWidth(),  
  9.                 height:menuEl.getHeight()  
  10.             });  
  11.     });  
  12.         tb.on('menuhide',function(toolbar,menu) {  
  13.             var shimmer = document.getElementById('shimmer')  
  14.             document.body.removeChild(shimmer);  
  15.     });  
  16. });  
  17.     function createShim(coordinate) {  
  18.         var shimmer = document.createElement('iframe');  
  19.         shimmer.id='shimmer';  
  20.         shimmer.style.position='absolute';  
  21.         shimmer.style.top=coordinate.top;  
  22.         shimmer.style.left=coordinate.left;  
  23.         shimmer.style.width=coordinate.width;  
  24.         shimmer.style.height=coordinate.height;  
  25.         shimmer.style.zIndex='999';  
  26.         shimmer.setAttribute('frameborder','0');  
  27.         shimmer.setAttribute('src','javascript:false;');  
  28.         document.body.appendChild(shimmer);  
  29. }   
   

转载于:https://www.cnblogs.com/lzlynn/archive/2008/10/06/1305111.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值