日期:2014-05-16  浏览次数:20307 次

如何FireFox下实现IE的showModalDialog的功能?
找遍了网络上的文章都是说设置一下 'modal=yes '   就可以,例如:
window.open( 'openwin.html ', 'newWin ', 'modal=yes,width=200,height=200,resizable=no,scrollbars=no ');  

实际上我在firefox   最新版本   2.0.0.6   上试过n遍,它只是打开一个窗口,窗口是可以随便切换的!!!   根本实现不了ie的showModalDialog的功能.  

请大家使用firefox2.006版本,测试一下,或者给个解决方案,谢谢!

有些朋友说可以,请注明一下你的firefox版本,谢谢!

------解决方案--------------------
用var win = window.showModalDialog()不行吗?呵呵。
------解决方案--------------------
可以用css模拟,网上很多
------解决方案--------------------
通过DIV模拟模态,代码
<html>
<head>
<style type= "text/css ">
#id1{width:100%;height:100%;background-color:red;position:absolute;top:0;left:0;z-index:49;display:none; filter:Alpha(opacity=25);
}
#id2{top:200px;position:absolute;z-index:50;display:none;border:3px solid #E5E5E5; left:100px;background-color:white;}
</style>
</head>
<body>
<div id= "id2 ">
<table height= "100 " width= "200 ">
<tr>
<td>
<div id= "ShowMSG "> </div>
</td>
</tr>
<tr>
<td align= "center "> <input class= "Button60 " onclick= "divhide() " type= "button " value= "close " name= "btnDo ">
</td>
</tr>
</table>
</div>
<input type= "button " onclick= "divshow( 'okok ') " value= "click ">
sdljfoguiougoshohgo
<div id= "id1 "> okokokokokokokoko </div>
</body>
<script language= "javascript ">
function divshow(showmsg){

document.getElementById( "id1 ").style.height=window.screen.height+ "px ";
document.getElementById( "id1 ").style.width=window.screen.width+ "px ";
document.getElementById( "id1 ").style.display= 'block ';
document.getElementById( "id2 ").style.display= 'block ';
document.getElementById( "ShowMSG ").innerText = showmsg;
}
function divhide(){
document.getElementById( "id1 ").style.display= 'none '
document.getElementById( "id2 ").style.display= 'none '
}

self.onError=null;
currentX = currentY = 0;
whichIt = null;
lastScrollX = 0; lastScrollY = 0;
NS = (document.layers) ? 1 : 0;
IE = (document.all) ? 1: 0;
<!-- STALKER CODE -->
function heartBeat(){
if(IE){ diffY = document.body.scrollTop; diffX = document.body.scrollLeft; }
if(NS){ diffY = self.pageYOffset; diffX = self.pageXOffset; }
if(diffY != lastScrollY){
percent = .1 * (diffY - lastScrollY);
if(percent > 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) document.all.id2.style.pixelTop += percent;
if(NS) document.id2.top += percent;
lastScrollY = lastScrollY + percent;
}
if(diffX != lastScrollX){
percent = .1