<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
  2. <html>  
  3. <head>  
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
  5. <title>关于div覆盖select标签的问题</title>  
  6. </head>  
  7. <body>  
  8. <input type="text" name="userName" value="" style="width:250px" />  
  9. <br/>  
  10. <br/>  
  11. <select id="state" name="state" style="width:255px">  
  12. <option value="0">苹''''''''''''''''''''''''''果</option>  
  13. <option value="1">香''''''''''''''''''''''''''蕉</option>  
  14. <option value="2">西''''''''''''''''''''''''''瓜</option>  
  15. </select>  
  16. <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>  
  17. <input type="button" name="bt1" value="显示DIV" οnclick="showDiv()"/>  
  18. <input type="button" name="bt2" value="关闭DIV" οnclick="closeDiv()"/>  
  19. <input type="button" name="bt3" value="启动iframe-->显示DIV" οnclick="showIframe()"/>  
  20. <input type="button" name="bt4" value="关闭iframe-->显示DIV" οnclick="closeIframe()"/>  
  21. </body>  
  22. <iframe   id="DivShim"  src="javascript:false;"  scrolling="no"  frameborder="0"  style="position:absolute; top:0px; left:0px; display:none;"></iframe>     
  23. <script type="text/javascript">  
  24.   
  25. var div;  
  26. var iframe;  
  27. function init()  
  28. {  
  29.     div = window.document.createElement("DIV");  
  30.     //z-index 属性设置元素的堆叠顺序。拥有更高堆叠顺序的元素总是会处于堆叠顺序较低的元素的前面  
  31.     div.style.zIndex=100;  
  32.     div.id="partName";  
  33.     div.style.display="none";  
  34.     window.document.body.insertAdjacentElement("beforeEnd",div);  
  35. }  
  36. init();  
  37. function showDiv()  
  38. {  
  39.     div.style.position ="absolute";  
  40.     div.style.backgroundColor="infobackground";  
  41.     div.style.overflowY="auto";  
  42.     div.style.overflowX="hidden";  
  43.     div.style.pixelTop=0;  
  44.     div.style.pixelLeft=0;  
  45.     div.style.pixelWidth=300;  
  46.     div.style.pixelHeight=200;  
  47.     div.style.display="block";  
  48. }  
  49. function closeDiv()  
  50. {  
  51.     div.style.display="none";  
  52. }  
  53. function showIframe()  
  54. {  
  55.     iframe=document.getElementById("DivShim");  
  56.     iframe.style.backgroundColor="red";  
  57.     iframe.style.top=0;  
  58.     iframe.style.left=0;  
  59.     iframe.style.display="block";  
  60.     iframe.style.width=300;  
  61.     iframe.style.height=200;  
  62. }  
  63. function closeIframe()  
  64. {  
  65.     iframe.style.width=0;  
  66.     iframe.style.width=0;  
  67. }  
  68. /**语法:  
  69. oElement = object . insertAdjacentElement ( sWhere , oElement )  
  70. 参数:  
  71. oElement :  必选项。对象(Element)。要插入到 object 邻近的对象。  
  72. sWhere :  必选项。字符串(String)。beforeBegin | afterBegin | beforeEnd | afterEnd beforeBegin :  将 oElement 插到 object 的开始标签之前。  
  73. afterBegin :  将 oElement 插到 object 的开始标签之后。但是在 object 的所有原有内容之前。  
  74. beforeEnd :  将 oElement 插到 object 的结束标签之前。但是在 object 的所有原有内容之后。  
  75. afterEnd :  将 oElement 插到 object 的结束标签之后。  
  76.  
  77. 返回值:  
  78. oElement :  对象(Element)。返回插入的对象的引用。  
  79. 说明:  
  80. 将 oElement 依据 object 定位插入文档结构。  
  81. 当文档正在载入时,不可以尝试此方法。必须在 onload 事件触发以后。  
  82. 假如你尝试插入一个已经在文档结构中存在定位的对象,该对象将被移动到你指定的插入位置,而不会有新对象被创建。 
  83. */  
  84. </script>  
  85. </html> 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值