window.opener.$("#lboxTM").append($("<option>111</option>"));为什么不能作用??
这里的lboxTM是父窗口的一个select
换作其他input 设置val()都是可以的

解决方案 »

  1.   

    try
    $(window.opener.document.body).children("#lboxTM").append("<option>111</option>");
      

  2.   


    貌似是执行过去了,但是父窗口还是没有任何改变。
    会不会是页面上有什么设置啊,aspx的页面
      

  3.   

    父窗口<select size="4" name="lboxTM" id="lboxTM" class="text" style="width:150px;"></select>
    子窗口的JS
       $(window.opener.document.body).children("#lboxTM").append("<option>111</option>");
         window.close();还是没反应。
      

  4.   

    没有代码,看不出问题所在,下面是我的测试代码,很征程
    1.htm<input type="button" id="a" onclick="window.open('2.htm');" />
    <select size="4" name="lboxTM" id="lboxTM" class="text" style="width:150px;"> </select> 2.htm
    <script type="text/javascript" src="jquery-1.2.6.min.js"> </script> 
    <script> 
    $(window.opener.document.body).children("#lboxTM").append(" <option>111 </option>"); 
    </script> 
      

  5.   


        function ApproverWindow(obj)
       {
         var selParent= $(obj).prev(".text").attr("id");     var WWidth=800;
         var WHeight=800;
         var   WLeft   =   Math.ceil((window.screen.width   -   WWidth)   /   2   );     
         var   WTop   =   Math.ceil((window.screen.height   -   WHeight)   /   2   );     
         var   features   =   
         'width='     +   WWidth     +   'px,'   +   
         'height='   +   WHeight     +   'px,'   +   
         'left='       +   WLeft     +   'px,'   +   
         'top='         +   WTop     +   'px,'   +   
         'fullscreen=0,   toolbar=0,   location=0,   directories=0,   status=0,   menubar=0,   scrollbars=1,   resizable=0'; 
         window.open("InsertApprovers.aspx?selParent="+selParent+"",  "",   features);   
        }
      <tr>
                    <td class="detailleft" width="40%">
                        TM
                    </td>
                    <td class="detailright" >
                    <select size="4" name="lboxTM" id="lboxTM" class="text" style="width:150px;"></select>
                     <input id="btnMore1" type="button" value=" More+" class="bluebutton" onclick="ApproverWindow(this)"/>
                    </td>
                </tr>InsertApprovers页面 function Insert()
       { $(window.opener.document.body).children("#lboxTM").append("<option>111</option>");
         window.close(); 
       }
     <input id="btnInsert" type="button" value="Insert" class="bluebutton" onclick="Insert()"/>
      

  6.   

    是不是lboxTM的ClientID 不是lboxTM?你用了母板页?
      

  7.   

    没用阿
    <select size="4" name="lboxTM" id="lboxTM" class="text" style="width:150px;"></select>
    这是源代码
      

  8.   

    那就奇怪了,我测试很正常
    1.htm
    <script type="text/javascript" src="jquery-1.2.6.min.js"> </script> 
    <script>
       function ApproverWindow(obj)
       {
         var selParent= $(obj).prev(".text").attr("id");     var WWidth=800;
         var WHeight=800;
         var   WLeft   =   Math.ceil((window.screen.width   -   WWidth)   /   2   );     
         var   WTop   =   Math.ceil((window.screen.height   -   WHeight)   /   2   );     
         var   features   =   
         'width='     +   WWidth     +   'px,'   +   
         'height='   +   WHeight     +   'px,'   +   
         'left='       +   WLeft     +   'px,'   +   
         'top='         +   WTop     +   'px,'   +   
         'fullscreen=0,   toolbar=0,   location=0,   directories=0,   status=0,   menubar=0,   scrollbars=1,   resizable=0'; 
         window.open("2.htm?"+selParent+"",  "",   features);   
        }
    </script><tr>
        <td class="detailleft" width="40%">
            TM
        </td>
        <td class="detailright" >
        <select size="4" name="lboxTM" id="lboxTM" class="text" style="width:150px;"></select>
         <input id="btnMore1" type="button" value=" More+" class="bluebutton" onclick="ApproverWindow(this)"/>
        </td>
    </tr>
    2.htm
    <HTML> 
    <HEAD> 
    <script type="text/javascript" src="jquery-1.2.6.min.js"> </script> 
    <script> 
     function Insert()
       { $(window.opener.document.body).children("#lboxTM").append("<option>111</option>");
         window.close(); 
       }
    </script> 
    <input id="btnInsert" type="button" value="Insert" class="bluebutton" onclick="Insert()"/>
      

  9.   

    window.opener.$("#lboxTM").append("<option>111</option>");
    貌似这样写又好用了。。
    你给的那个方法我还是不好用唉~~
    谢谢哦
      

  10.   

    var url1 = "http://192.168.1.88/511/productclass.asp?act=low&page=2";
    var url2 = "http://192.168.1.88/511/productclass.asp?page=2&act=low";alert(clearPage(url1));
    alert(clearPage(url2));
    function clearPage(url)
    {
        return url.replace(/[?&]page=\d&{0,}/g,function(m)
        {
            return m.charAt(0)=="&" ? "" : "?";
        });
    }
      

  11.   

    借用网友 kbwood.au  的回答:
    $('#text', window.opener.document).val(txt.value);
    (来自jquery论坛 http://forum.jquery.com/topic/using-jquery-from-a-popup-window)