由于ie7安全性更高,对很多涉及安全的东西都进行了修改,所以在IE7中使用showModalDialog地址栏将会显示,在ie6中地址栏是不显示的,所以高度自然就不一样,下面的实例代码实现了showModalDialog高度自动适应不同浏览器版本。
<JAVASCRIPT> function SelectUserGroup(lid,id){ var dialogheight=resetDialogHeight(); var arr=showModalDialog(’Calculation.asp?lid=’+lid+’&id=’+id, ’’, ’dialogWidth:250px; dialogHeight:’+dialogheight+’px; help: no; scroll: no; status: no’); } /** * 根据操作系统及ie不同版本,重新设置窗口高度,避免底部按钮被遮住. */ function resetDialogHeight(){ var ua = navigator.userAgent; if(ua.lastIndexOf("MSIE 5.5") != -1){ return 205; } if(ua.lastIndexOf("MSIE 6.0") != -1){ return 205; } if(ua.lastIndexOf("MSIE 7.0") != -1){ return 155; } if(ua.lastIndexOf("Firefox") != -1){ return 160; } } </script>