<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 495,comments - 227,trackbacks - 0
    ?? 在b\s系統(tǒng)中,用戶經(jīng)常需要打開子窗口選中某些項目,并將這些項目插入到父窗口的下拉選框中。本來以為在IE中實現(xiàn)這樣子窗口操作父窗口的功能十分簡單,但是按常規(guī)的做法卻是行不通的。在google上搜索了一陣也沒有好的解決方案。最后看到國外的一個網(wǎng)頁上有以下內(nèi)容:

    Explorer 5.0 problems

    When it comes to dynamically generating options and selects, Explorer 5.0 on Windows has quite a few problems:

    1. 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
    2. 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 through innerHTML instead.
    3. 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:

    var?doc?=?select.ownerDocument;
    if?(!doc)
    ????doc?
    =?select.document;
    var?opt?=?doc.createElement('OPTION');
    opt.value?
    =?value;
    opt.text?
    =?text;
    select.options.add(opt,?index);

    ??? 最后得到了啟發(fā),從而實現(xiàn)了這個功能,下面所有可能用到的實現(xiàn)方法的代碼。但是在這些代碼中有些方法是不可行的。最后有一個表格說明了哪些方法不可行,理由是什么?

    HTMLPage.htm

    <!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html?xmlns="http://www.w3.org/1999/xhtml"?>
    <head>
    ????
    <title>1st</title>
    ????
    <script?language="javascript">
    ????
    function?AddOpt(text,val)
    ????
    {
    ????????
    var?slct?=?document.getElementById("Select1");
    ????????
    var?op?=?new?Option(text,val);
    ????????slct.add(op);
    ????}

    ????
    </script>
    </head>
    <body>
    <form?id="form1"?name="form1">
    ????
    <select?id="Select1"?multiple="multiple">
    ????????
    <option?selected="selected"?value="1">1</option>
    ????????
    <option?value="2">2</option>
    ????????
    <option?value="3">3</option>
    ????????
    <option?value="4">4</option>
    ????
    </select>
    ????
    <br?/>
    ????
    <input?id="showModalDialogWithoutArg"?type="button"?value="showModalDialogWithoutArg"?onclick="window.showModalDialog('HTMLPage2.htm');"/>
    ????
    <br?/>
    ????
    <input?id="showModalDialogWithArg"?type="button"?value="showModalDialogWithArg"?onclick="window.showModalDialog('HTMLPage2.htm',?window);"/>
    ????
    <br?/>
    ????
    <input?id="showModelessDialogWithoutArg"?type="button"?value="showModelessDialogWithoutArg"?onclick="window.showModelessDialog('HTMLPage2.htm');"/>
    ????
    <br?/>
    ????
    <input?id="showModelessDialogWithArg"?type="button"?value="showModalDialogWithArg"?onclick="window.showModelessDialog('HTMLPage2.htm',?window);"/>
    ????
    <br?/>
    ????
    <input?id="open"?type="button"?value="open"?onclick="window.open('HTMLPage2.htm');"/>
    </form>
    </body>
    </html>

    ?HTMLPage2.htm

    <!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html?xmlns="http://www.w3.org/1999/xhtml"?>
    <head>
    ????
    <title>2nd</title>
    ????
    <script?language="javascript">
    ????
    function?InsertToParent()
    ????
    {
    ????????
    var?slct?=?window.parent.document.getElementById("Select1");
    ????????
    ????????doc?
    =?slct.ownerDocument;
    ????????
    var?opt?=?doc.createElement('OPTION');
    ????????opt.value?
    =?"2nd?窗口";
    ????????opt.text?
    =?"2nd?窗口";
    ????????slct.options.add(opt);
    ????}

    ????
    ????
    function?InsertToOpener()
    ????
    {
    ????????
    var?slct?=?window.opener.document.getElementById("Select1");
    ????????
    ????????doc?
    =?slct.ownerDocument;
    ????????
    var?opt?=?doc.createElement('OPTION');
    ????????opt.value?
    =?"2nd?窗口";
    ????????opt.text?
    =?"2nd?窗口";
    ????????slct.options.add(opt);
    ????}

    ????
    ????
    function?InsertToTop()
    ????
    {
    ????????
    var?slct?=?window.top.document.getElementById("Select1");
    ????????
    ????????doc?
    =?slct.ownerDocument;
    ????????
    var?opt?=?doc.createElement('OPTION');
    ????????opt.value?
    =?"2nd?窗口";
    ????????opt.text?
    =?"2nd?窗口";
    ????????slct.options.add(opt);
    ????}

    ????
    ????
    function?InsertByParentFun()
    ????
    {
    ????????
    var?wnd?=?window.parent;
    ????????wnd.AddOpt(
    "2nd?窗口","2nd?窗口");
    ????}

    ????
    ????
    function?InsertByOpenerFun()
    ????
    {
    ????????
    var?wnd?=?window.opener;
    ????????wnd.AddOpt(
    "2nd?窗口","2nd?窗口");
    ????}

    ????
    ????
    function?InsertByTopFun()
    ????
    {???????
    ????????
    var?wnd?=?window.top;
    ????????wnd.AddOpt(
    "2nd?窗口","2nd?窗口");
    ????}

    ????
    ????
    function?InsertByArgFun()
    ????
    {
    ????????
    var?wnd?=?window.dialogArguments;
    ????????wnd.AddOpt(
    "2nd?窗口","2nd?窗口");
    ????}

    ????
    ????
    function?InsertWithArg()
    ????
    {
    ????????
    var?wnd?=?window.dialogArguments;
    ????????
    var?doc?=?wnd.document;
    ????????
    var?slct?=?doc.getElementById("Select1");
    ????????
    ????????doc?
    =?slct.ownerDocument;
    ????????
    var?opt?=?doc.createElement('OPTION');
    ????????opt.value?
    =?"2nd?窗口";
    ????????opt.text?
    =?"2nd?窗口";
    ????????slct.options.add(opt);
    ????}

    ????
    </script>
    </head>
    <body>
    ????
    <input?id="InsertToParent"?type="button"?value="InsertToParent"?onclick="InsertToParent()"?/>
    ????
    <br?/>
    ????
    <input?id="InsertToOpener"?type="button"?value="InsertToOpener"?onclick="InsertToOpener()"?/>
    ????
    <br?/>
    ????
    <input?id="InsertToTop"?type="button"?value="InsertToTop"?onclick="InsertToTop()"?/>
    ????
    <br?/>
    ????
    <input?id="InsertByParentFun"?type="button"?value="InsertByParentFun"?onclick="InsertByParentFun()"?/>
    ????
    <br?/>
    ????
    <input?id="InsertByOpenerFun"?type="button"?value="InsertByOpenerFun"?onclick="InsertByOpenerFun()"?/>
    ????
    <br?/>
    ????
    <input?id="InsertByTopFun"?type="button"?value="InsertByTopFun"?onclick="InsertByTopFun()"?/>
    ????
    <br?/>
    ????
    <input?id="InsertByArgFun"?type="button"?value="InsertByArgFun"?onclick="InsertByArgFun()"?/>
    ????
    <br?/>
    ????
    <input?id="InsertWithArg"?type="button"?value="InsertWithArg"?onclick="InsertWithArg()"?/>
    </body>
    </html>

    ?

    方法表格

    showModalDialogWithoutArg

    InsertToParent

    不能實現(xiàn)

    子窗口parent屬性為子窗口自身

    InsertToOpener

    不能實現(xiàn)

    子窗口opener屬性為空

    InsertToTop

    不能實現(xiàn)

    子窗口top屬性為子窗口自身

    InsertByParentFun

    不能實現(xiàn)

    子窗口parent屬性為子窗口自身

    InsertByOpenerFun

    不能實現(xiàn)

    子窗口opener屬性為空

    InsertByTopFun

    不能實現(xiàn)

    子窗口top屬性為子窗口自身

    InsertByArgFun

    不能實現(xiàn)

    沒有傳送參數(shù)給子窗口

    InsertWithArg

    不能實現(xiàn)

    沒有傳送參數(shù)給子窗口

    showModalDialogWithArg

    InsertToParent

    不能實現(xiàn)

    子窗口parent屬性為子窗口自身

    InsertToOpener

    不能實現(xiàn)

    子窗口opener屬性為空

    InsertToTop

    不能實現(xiàn)

    子窗口top屬性為子窗口自身

    InsertByParentFun

    不能實現(xiàn)

    子窗口parent屬性為子窗口自身

    InsertByOpenerFun

    不能實現(xiàn)

    子窗口opener屬性為空

    InsertByTopFun

    不能實現(xiàn)

    子窗口top屬性為子窗口自身

    InsertByArgFun

    可以實現(xiàn)

    ?

    InsertWithArg

    可以實現(xiàn)

    ?

    showModelessDialogWithoutArg

    InsertToParent

    不能實現(xiàn)

    子窗口parent屬性為子窗口自身

    InsertToOpener

    不能實現(xiàn)

    子窗口opener屬性為空

    InsertToTop

    不能實現(xiàn)

    子窗口top屬性為子窗口自身

    InsertByParentFun

    不能實現(xiàn)

    子窗口parent屬性為子窗口自身

    InsertByOpenerFun

    不能實現(xiàn)

    子窗口opener屬性為空

    InsertByTopFun

    不能實現(xiàn)

    子窗口top屬性為子窗口自身

    InsertByArgFun

    不能實現(xiàn)

    沒有傳送參數(shù)給子窗口

    InsertWithArg

    不能實現(xiàn)

    沒有傳送參數(shù)給子窗口

    showModelessDialogWithArg

    InsertToParent

    不能實現(xiàn)

    子窗口parent屬性為子窗口自身

    InsertToOpener

    不能實現(xiàn)

    子窗口opener屬性為空

    InsertToTop

    不能實現(xiàn)

    子窗口top屬性為子窗口自身

    InsertByParentFun

    不能實現(xiàn)

    子窗口parent屬性為子窗口自身

    InsertByOpenerFun

    不能實現(xiàn)

    子窗口opener屬性為空

    InsertByTopFun

    不能實現(xiàn)

    子窗口top屬性為子窗口自身

    InsertByArgFun

    可以實現(xiàn)

    ?

    InsertWithArg

    可以實現(xiàn)

    ?

    open

    InsertToParent

    不能實現(xiàn)

    子窗口parent屬性為子窗口自身

    InsertToOpener

    可以實現(xiàn)

    ?

    InsertToTop

    不能實現(xiàn)

    子窗口top屬性為子窗口自身

    InsertByParentFun

    不能實現(xiàn)

    子窗口parent屬性為子窗口自身

    InsertByOpenerFun

    可以實現(xiàn)

    ?

    InsertByTopFun

    不能實現(xiàn)

    子窗口top屬性為子窗口自身

    InsertByArgFun

    不能實現(xiàn)

    open方法不能在窗口間傳遞參數(shù)

    InsertWithArg

    不能實現(xiàn)

    open方法不能在窗口間傳遞參數(shù)



    Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1089313

    posted on 2006-09-07 12:39 SIMONE 閱讀(617) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲已满18点击进入在线观看| 亚洲精品电影在线| 亚洲av午夜成人片精品网站| 日韩国产免费一区二区三区| 成年性生交大片免费看| 午夜国产羞羞视频免费网站| 国产亚洲精品无码专区| 亚洲久本草在线中文字幕| 亚洲天堂电影在线观看| 亚洲AV无码男人的天堂| 美女巨胸喷奶水视频www免费| 香蕉国产在线观看免费| 精品国产一区二区三区免费| 人妻在线日韩免费视频| 91免费在线播放| 四虎国产精品免费视| 亚洲av永久无码精品网站 | 国产精品成人免费视频网站京东 | 亚洲中文无码线在线观看| 亚洲av永久无码一区二区三区| 国产福利在线观看永久免费| xxxxwww免费| 一本久到久久亚洲综合| 亚洲最大成人网色| 色欲aⅴ亚洲情无码AV蜜桃| 国产在线观看xxxx免费| 成年免费大片黄在线观看岛国| 亚洲国产黄在线观看| 麻豆亚洲AV永久无码精品久久| 亚洲AV噜噜一区二区三区| 国产午夜免费高清久久影院| 免费网站看v片在线香蕉| 亚洲人成中文字幕在线观看| 亚洲日韩精品无码专区网址| 亚洲91精品麻豆国产系列在线| 九九免费观看全部免费视频| 美女被免费喷白浆视频| 亚洲一区二区三区AV无码| 亚洲乱码在线观看| 嫩草影院在线播放www免费观看| 国产成人精品男人免费|