无法访问弹出窗口对象 [英] unable to access pop up window objects
问题描述
弹出窗口有几个复选框。我无法使用window.open中的句柄访问
复选框。有没有办法呢?
var display;
函数showSugg(but_id,sugg1,sugg2,sugg3,sugg4,sugg5){
display = window.open('''','_ blank'',''menubar = 0,locatio n = no,status = no,directories = no,toolbar = no,scrollbar s =是的,身高= 150,宽度= 190'')
var message ="< font face =''verdana,arial,helvetica,
san-serif''size =''2''>< table>" ;;
message + ="< tr>< td>" + sugg1 +"< / td> < td>< input
type = checkbox name = mycheck1 value = \''" + sugg1 +
" \''onClick = \" self.opener.document.forms [0]。 + but_id +
" .value = \''" + sugg1 +" \'';"
+" document.mycheck2.checked = false; mycheck3.checked = false;" +
" mycheck4.checked =假;" +
" mycheck5.checked = false;" +" \">< / td>< / tr>" ;;
}
The pop up window has several checkboxes. I''m unable to access the
checkboxes using the handle from window.open. Any way to do this?
var display;
function showSugg(but_id, sugg1, sugg2, sugg3, sugg4, sugg5) {
display=window.open('''',''_blank'',''menubar=0,locatio n=no,status=no,directories=no,toolbar=no,scrollbar s=yes,height=150,width=190'')
var message="<font face=''verdana, arial, helvetica,
san-serif'' size=''2''><table>";
message += "<tr><td>" + sugg1 + "</td> <td><input
type=checkbox name=mycheck1 value=\''" + sugg1 +
"\'' onClick=\"self.opener.document.forms[0]." + but_id +
".value=\''" + sugg1 + "\'';"
+ "document.mycheck2.checked=false;mycheck3.checked= false;" +
" mycheck4.checked=false;" +
"mycheck5.checked=false;" + "\"></td></tr>";
}
推荐答案
所以*********** @ yahoo.com 说:
弹出窗口有几个复选框。我无法使用window.open中的句柄访问
复选框。有什么办法吗?
var display;
函数showSugg(but_id,sugg1,sugg2,sugg3,sugg4,sugg5){
display = window.open ('''',''_ blank'',''menubar = 0,locati on = no,status = no,directories = no,toolbar = no,scrollba rs = yes,height = 150,width = 190'')
var message ="< font face =''verdana,arial,helvetica,
san-serif''size ='''''>< table>" ;
消息+ ="< tr>< td>" + sugg1 +"< / td> < td>< input
type = checkbox name = mycheck1 value = \''" + sugg1 +
" \''onClick = \" self.opener.document.forms [0]。 + but_id +
" .value = \''" + sugg1 +" \'';"
+" document.mycheck2.checked = false; mycheck3.checked = false;" +
mycheck4.checked =假;" +
" mycheck5.checked = false;" +" \">< / td>< / tr>" ;;
}
The pop up window has several checkboxes. I''m unable to access the
checkboxes using the handle from window.open. Any way to do this?
var display;
function showSugg(but_id, sugg1, sugg2, sugg3, sugg4, sugg5) {
display=window.open('''',''_blank'',''menubar=0,locati on=no,status=no,directories=no,toolbar=no,scrollba rs=yes,height=150,width=190'')
var message="<font face=''verdana, arial, helvetica,
san-serif'' size=''2''><table>";
message += "<tr><td>" + sugg1 + "</td> <td><input
type=checkbox name=mycheck1 value=\''" + sugg1 +
"\'' onClick=\"self.opener.document.forms[0]." + but_id +
".value=\''" + sugg1 + "\'';"
+ "document.mycheck2.checked=false;mycheck3.checked= false;" +
" mycheck4.checked=false;" +
"mycheck5.checked=false;" + "\"></td></tr>";
}
您显示的代码我们打开一个空白窗口,然后将一个字符串
值分配给名为message的变量。没有复选框。
The code you''ve shown us opens a blank window and then assigns a string
value to a variable named "message". There are no checkboxes.
Lee写道:
Lee wrote:
所以*********** @ yahoo.com 说:
弹出窗口有几个复选框。我无法使用window.open中的句柄访问
复选框。有什么办法吗?
var display;
函数showSugg(but_id,sugg1,sugg2,sugg3,sugg4,sugg5){
display = window.open ('''',''_ blank'',''menubar = 0,locati on = no,status = no,directories = no,toolbar = no,scrollba rs = yes,height = 150,width = 190'')
var message ="< font face =''verdana,arial,helvetica,
san-serif''size ='''''>< table>" ;
消息+ ="< tr>< td>" + sugg1 +"< / td> < td>< input
type = checkbox name = mycheck1 value = \''" + sugg1 +
" \''onClick = \" self.opener.document.forms [0]。 + but_id +
" .value = \''" + sugg1 +" \'';"
+" document.mycheck2.checked = false; mycheck3.checked = false;" +
mycheck4.checked =假;" +
" mycheck5.checked = false;" +" \">< / td>< / tr>" ;;
}
The pop up window has several checkboxes. I''m unable to access the
checkboxes using the handle from window.open. Any way to do this?
var display;
function showSugg(but_id, sugg1, sugg2, sugg3, sugg4, sugg5) {
display=window.open('''',''_blank'',''menubar=0,locati on=no,status=no,directories=no,toolbar=no,scrollba rs=yes,height=150,width=190'')
var message="<font face=''verdana, arial, helvetica,
san-serif'' size=''2''><table>";
message += "<tr><td>" + sugg1 + "</td> <td><input
type=checkbox name=mycheck1 value=\''" + sugg1 +
"\'' onClick=\"self.opener.document.forms[0]." + but_id +
".value=\''" + sugg1 + "\'';"
+ "document.mycheck2.checked=false;mycheck3.checked= false;" +
" mycheck4.checked=false;" +
"mycheck5.checked=false;" + "\"></td></tr>";
}
您向我们展示的代码会打开一个空白窗口然后将一个字符串
值分配给名为message的变量。没有复选框。
The code you''ve shown us opens a blank window and then assigns a string
value to a variable named "message". There are no checkboxes.
对不起。这是完整的代码。再次感谢:
var display;
函数showSugg(but_id,sugg1,sugg2,sugg3,sugg4,sugg5){
>
display = window.open('''',''_ blank'',''menubar = 0,locatio n = no,status = no,directories = no,toolbar = no,scrollbar s = yes, height = 150,width = 190'')
var screen_height = window.screen.availHeight;
var screen_width = window.screen.availWidth;
var left_point = parseInt(screen_width / 2);
var top_point = parseInt(screen_height / 2);
display.moveTo(left_point,top_point) ;
display.focus();
display.document.write("< input type = hidden name = a1>");
// alert(" display elements" + display.document.elements);
var message ="< font face =''verdana,arial,helvetica, san-serif''
size ='''2''>< table>" ;;
message + ="< tr>< td> " + sugg1 +"< / td> < td>< input
type = checkbox name = mycheck1 value = \''" + sugg1 +
" \''onClick = \" self.opener.document.forms [0]。 + but_id +
" .value = \''" + sugg1 +" \'';"
+" self.opener.document.forms [0]。 + but_id +
" .style.backgroundColor = \''#ffffff \'';"
+" self.opener.document.forms [ 。0]" + but_id +
" .style.color = \''#000000 \'';"
+
" display.document.mycheck2.checked = false; display.m ycheck3.checked = false;"
+
" display.mycheck4.checked =假;" +
" display.mycheck5.checked = false;" +" \">< / td>< / tr>" ;;
message + ="< tr>< td>" + sugg2 + < / td>< td>< input type = checkbox
name = mycheck2 value =" + sugg2 +
"的onClick = \" document.forms [0]" + but_id +" .value =" + sugg2
+" \">< / td>< / tr>" ;;
message + ="< ; TR>< TD>" + sugg3 + < / td>< td>< input type = checkbox
name = mycheck3 value =" + sugg3 +
"的onClick = \" document.forms [0]" + but_id +" .value =" + sugg3 +
" \">< / td>< / tr>" ;;
message + ="< ; TR>< TD>" + sugg4 + < / td>< td>< input
type = checkbox name = mycheck4 value =" + sugg4 +
"的onClick = \" document.forms [0]" + but_id +" .value =" + sugg4
+" \">< / td>< / tr>" ;;
message + ="< ; TR>< TD>" + sugg5 + < / td>< td>< input
type = checkbox name = mycheck5 value =" + sugg5 +
"的onClick = \" document.forms [0]" + but_id +" .value =" + sugg5
+" \">< / td>< / tr>" ;;
message + ="< / table>< ; / font>" ;;
// alert(消息);
display.document.write(message);
}
Sorry. Here is the full code. Many thanks again:
var display;
function showSugg(but_id, sugg1, sugg2, sugg3, sugg4, sugg5) {
display=window.open('''',''_blank'',''menubar=0,locatio n=no,status=no,directories=no,toolbar=no,scrollbar s=yes,height=150,width=190'')
var screen_height = window.screen.availHeight;
var screen_width = window.screen.availWidth;
var left_point = parseInt(screen_width / 2);
var top_point = parseInt(screen_height/2);
display.moveTo(left_point, top_point);
display.focus();
display.document.write("<input type=hidden name=a1>");
//alert("display elements" + display.document.elements);
var message="<font face=''verdana, arial, helvetica, san-serif''
size=''2''><table>";
message += "<tr><td>" + sugg1 + "</td> <td><input
type=checkbox name=mycheck1 value=\''" + sugg1 +
"\'' onClick=\"self.opener.document.forms[0]." + but_id +
".value=\''" + sugg1 + "\'';"
+ "self.opener.document.forms[0]." + but_id +
".style.backgroundColor=\''#ffffff\'';"
+ "self.opener.document.forms[0]." + but_id +
".style.color=\''#000000\'';"
+
"display.document.mycheck2.checked=false;display.m ycheck3.checked=false;"
+
" display.mycheck4.checked=false;" +
"display.mycheck5.checked=false;" + "\"></td></tr>";
message += "<tr><td>" +sugg2 + " </td><td><input type=checkbox
name=mycheck2 value=" + sugg2 +
" onClick=\"document.forms[0]." + but_id + ".value=" + sugg2
+"\"></td></tr>";
message += "<tr><td>" +sugg3 + " </td><td><input type=checkbox
name=mycheck3 value=" + sugg3 +
" onClick=\"document.forms[0]." + but_id + ".value=" + sugg3 +
"\"></td></tr>";
message += "<tr><td>" +sugg4 + " </td><td><input
type=checkbox name=mycheck4 value=" + sugg4 +
" onClick=\"document.forms[0]." + but_id + ".value=" + sugg4
+ "\"></td></tr>";
message += "<tr><td>" +sugg5 + " </td><td><input
type=checkbox name=mycheck5 value=" + sugg5 +
" onClick=\"document.forms[0]." + but_id + ".value=" + sugg5
+ "\"></td></tr>";
message+="</table></font>";
//alert(message);
display.document.write(message);
}
所以*** ********@yahoo.com 写道:
我无法访问
使用window.open中的句柄复选框。
I''m unable to access the
checkboxes using the handle from window.open.
你的意思是什么你不能?怎么了?你尝试了什么?那里的
代码在哪里?
display.document.write("< input type = hidden name = a1>");
在写()之前你应该打开()
display.document.write(message);
What do you mean you''re unable? What happens? What did you try? Where''s the
code for that?
display.document.write("<input type=hidden name=a1>");
Before doing a write() you should do an open()
display.document.write(message);
然后你应该在完成后关闭()。
此外,弹出窗口中的HTML无效。没有html标签,没有正文标签,
没有表格标签等等。
然后真正的问题是,从你的弹出代码中,你不应该''是
引用''显示''。相反,只需使用document.forms [0] .mycheck2等。
-
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
这篇关于无法访问弹出窗口对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!