jquery window.opener append() 问题??? window.opener.$("#lboxTM").append($("<option>111</option>"));为什么不能作用??这里的lboxTM是父窗口的一个select换作其他input 设置val()都是可以的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 try$(window.opener.document.body).children("#lboxTM").append("<option>111</option>"); 貌似是执行过去了,但是父窗口还是没有任何改变。会不会是页面上有什么设置啊,aspx的页面 父窗口<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();还是没反应。 没有代码,看不出问题所在,下面是我的测试代码,很征程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> 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()"/> 是不是lboxTM的ClientID 不是lboxTM?你用了母板页? 没用阿<select size="4" name="lboxTM" id="lboxTM" class="text" style="width:150px;"></select>这是源代码 那就奇怪了,我测试很正常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()"/> window.opener.$("#lboxTM").append("<option>111</option>");貌似这样写又好用了。。你给的那个方法我还是不好用唉~~谢谢哦 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)=="&" ? "" : "?"; });} 借用网友 kbwood.au 的回答:$('#text', window.opener.document).val(txt.value);(来自jquery论坛 http://forum.jquery.com/topic/using-jquery-from-a-popup-window) 求正则表达式一个,替换href中的内容 关于循环传值问题 关于全局变量与局部变量 求一款博客类型的日期控件 JSON:修改字段值~~~急 关于window.open的问题 高手帮忙呀(Soft Keyboard) 如何解析html头部分格式 怎么样给一个网页设定name? 导航菜单点击后,被选中项css变化 求代码 js如何取对象的属性名? js 弹出层
$(window.opener.document.body).children("#lboxTM").append("<option>111</option>");
貌似是执行过去了,但是父窗口还是没有任何改变。
会不会是页面上有什么设置啊,aspx的页面
子窗口的JS
$(window.opener.document.body).children("#lboxTM").append("<option>111</option>");
window.close();还是没反应。
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>
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()"/>
<select size="4" name="lboxTM" id="lboxTM" class="text" style="width:150px;"></select>
这是源代码
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()"/>
貌似这样写又好用了。。
你给的那个方法我还是不好用唉~~
谢谢哦
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)=="&" ? "" : "?";
});
}
$('#text', window.opener.document).val(txt.value);
(来自jquery论坛 http://forum.jquery.com/topic/using-jquery-from-a-popup-window)