在b/s系统中,用户经常需要打开子窗口选中某些项目,并将这些项目插入到父窗口的下拉选框中。本来以为在IE中实现这样子窗口操作父窗口的功能十分简单,但是按常规的做法却是行不通的。在google上搜索了一阵也没有好的解决方案。最后看到国外的一个网页上有以下内容:
Explorer 5.0 problems
When it comes to dynamically generating options and selects, Explorer 5.0 on Windows has quite a few problems:
- Generating options in another frame or window doesn't work. Put the script in the page that contains the select. I have heard, but did not test, that this problem still exists in Explorer 6.0
- Generating selects and options through the 'pure' W3C DOM (ie. with any
document.createElement()
) crashes Explorer 5.0 . Solved in 5.5
Generate these selects and options throughinnerHTML
instead. - Generating options from a popup window may crash any Explorer Windows.
I have heard, but did not test, that the script below works fine in IE 5.0:








最后得到了启发,从而实现了这个功能,下面所有可能用到的实现方法的代码。但是在这些代码中有些方法是不可行的。最后有一个表格说明了哪些方法不可行,理由是什么?
HTMLPage.htm





































HTMLPage2.htm








































































































showModalDialogWithoutArg |
InsertToParent |
不能实现 |
子窗口parent属性为子窗口自身 |
InsertToOpener |
不能实现 |
子窗口opener属性为空 | |
InsertToTop |
不能实现 |
子窗口top属性为子窗口自身 | |
InsertByParentFun |
不能实现 |
子窗口parent属性为子窗口自身 | |
InsertByOpenerFun |
不能实现 |
子窗口opener属性为空 | |
InsertByTopFun |
不能实现 |
子窗口top属性为子窗口自身 | |
InsertByArgFun |
不能实现 |
没有传送参数给子窗口 | |
InsertWithArg |
不能实现 |
没有传送参数给子窗口 | |
showModalDialogWithArg |
InsertToParent |
不能实现 |
子窗口parent属性为子窗口自身 |
InsertToOpener |
不能实现 |
子窗口opener属性为空 | |
InsertToTop |
不能实现 |
子窗口top属性为子窗口自身 | |
InsertByParentFun |
不能实现 |
子窗口parent属性为子窗口自身 | |
InsertByOpenerFun |
不能实现 |
子窗口opener属性为空 | |
InsertByTopFun |
不能实现 |
子窗口top属性为子窗口自身 | |
InsertByArgFun |
可以实现 |
| |
InsertWithArg |
可以实现 |
| |
showModelessDialogWithoutArg |
InsertToParent |
不能实现 |
子窗口parent属性为子窗口自身 |
InsertToOpener |
不能实现 |
子窗口opener属性为空 | |
InsertToTop |
不能实现 |
子窗口top属性为子窗口自身 | |
InsertByParentFun |
不能实现 |
子窗口parent属性为子窗口自身 | |
InsertByOpenerFun |
不能实现 |
子窗口opener属性为空 | |
InsertByTopFun |
不能实现 |
子窗口top属性为子窗口自身 | |
InsertByArgFun |
不能实现 |
没有传送参数给子窗口 | |
InsertWithArg |
不能实现 |
没有传送参数给子窗口 | |
showModelessDialogWithArg |
InsertToParent |
不能实现 |
子窗口parent属性为子窗口自身 |
InsertToOpener |
不能实现 |
子窗口opener属性为空 | |
InsertToTop |
不能实现 |
子窗口top属性为子窗口自身 | |
InsertByParentFun |
不能实现 |
子窗口parent属性为子窗口自身 | |
InsertByOpenerFun |
不能实现 |
子窗口opener属性为空 | |
InsertByTopFun |
不能实现 |
子窗口top属性为子窗口自身 | |
InsertByArgFun |
可以实现 |
| |
InsertWithArg |
可以实现 |
| |
open |
InsertToParent |
不能实现 |
子窗口parent属性为子窗口自身 |
InsertToOpener |
可以实现 |
| |
InsertToTop |
不能实现 |
子窗口top属性为子窗口自身 | |
InsertByParentFun |
不能实现 |
子窗口parent属性为子窗口自身 | |
InsertByOpenerFun |
可以实现 |
| |
InsertByTopFun |
不能实现 |
子窗口top属性为子窗口自身 | |
InsertByArgFun |
不能实现 |
open方法不能在窗口间传递参数 | |
InsertWithArg |
不能实现 |
open方法不能在窗口间传递参数 |