今天用Firefox测了自己以前的写的部分页面,发现很多地方浏览不正常。
主要原因是Firefox和IE对javascript 的支持不一样。
以使用打开新窗的脚本为例,
IE支持window.showModalDialog, window.showModelessDialog, window.open,
而Firefox只支持window.open.

仔细对比了一下,发现以下特点:
在IE中,
1. window.showModalDialog打开的是真正的模态窗体。
2. window.showModelessDialog打开的不是模态窗体,但始终在opener的前面,focus可以回到opener.
3. window.open正常打开窗体。
在Firefox中,
1. Firefox不能打开真正的模态窗体。
2. 如果window.open的参数中设定了modal=yes,则与IE中window.showModelessDialog类似。
3. 如果window.open的参数中没有设定modal=yes,则与IE中window.open类似。

要使脚本可以在IE和Firefox中都正常运行,
可以按如下方式写:

1 if (window.showModalDialog != null)  // IE
2 {
3     window.showModalDialog(url, '', sFeatures);    
4 }
5 else // firefox 
6 {
7     window.open(url, name, 'modal=yes');
8 }
9 


上述代码可以在IE和Firefox中正常运行,其它浏览器没测过。
不过Netscape早期的版本和Opera似乎都不支持打开模式窗体。

相关文章:

  • 2021-08-29
  • 2022-12-23
  • 2021-07-12
  • 2022-02-20
  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-23
  • 2021-08-28
  • 2022-01-06
  • 2022-01-21
相关资源
相似解决方案