我正在做以下事情:
1)用户点击页面并打开弹出窗口。 2)在弹出窗口中,我尝试在父页面中设置一个文本框。
问题是代码在IE中有效,但在Fire Fox中不起作用。我正在测试FF 3.6.13。我假设它必须对window.opener.document.getElementById或self.opener.document.getElementById做一些事情。我尝试了两条线,它们在FF中不起作用。
function passValues(comment_text_box_id)
{
var checkbox_values = "";
for(i=0; i<document.form1.elements.length; i++)
{
if(document.form1.elements[i].type=="checkbox")
{
if(document.form1.elements[i].checked == true)
{
if(checkbox_values == ""){
checkbox_values = document.form1.elements[i].value;
}
else{
checkbox_values = checkbox_values + "," + document.form1.elements[i].value;
}
}
}
}
//window.opener.document.getElementById(comment_text_box_id).innerText = window.opener.document.getElementById(comment_text_box_id).innerText + checkbox_values;
self.opener.document.getElementById(comment_text_box_id).innerText = self.opener.document.getElementById(comment_text_box_id).innerText + checkbox_values;
}
答案 0 :(得分:0)
innerText 。在其他浏览器中,创建包含给定文本的TextNode,并将TextNode插入到target-element中。 将最后一行替换为:
self.opener.document.getElementById(comment_text_box_id)
.appendChild(self.opener.document.createTextNode(checkbox_values));
(如果文本不包含html-markup,则使用innerHTML)
答案 1 :(得分:0)
修改强> 用Javascript Framework替换单词ajax .. Jquery,Mootools等等......
为什么不使用ajax并创建一个模式html“popup”,这样你就可以一直保留在父页面的上下文中,并且你可以根据xmlHttpRequest对象返回的内容修改你的“父”页面。使用这种技术会受益,因为它会阻止您的页面被弹出窗口阻止程序阻止。
以下是我在搜索modal html dialog box
http://www.dhtmlgoodies.com/scripts/modal-message/demo-modal-message.html