rehanazher
03-14-2009, 02:45 PM
Hi All,
Firstly I know this issue has been addresses a lot already but as a newbie to HTML and Web Development I am unable to get the idea.
according to documentations and solutions proposed on different forums a popup or child window can be only closed using window.close() if it is opened via window.open() function.
Below is my code for opening the popup:
function getPorts(form){
var odfid = form.cmbodf.options[form.cmbodf.options.selectedIndex].value;
window.open('odfPorts.php?id='+odfid,'popuppage','width=515,titlebar=0,title=Select ODF,toolbar=0,resizable=0,scrollbars=no,height=500,top=150,left=500');
}
hence I am using window.open() to open window, ideally it should be closed using window.close().
Following is my code to close the pop up(it is validating some check boxes status and passing values to parent form and then is supposed to be closed)
function CheckCheckboxes(form, ot){
var elLength = form.elements.length;
var portNo=new Array(2);
var a=0;
if (ot==1){
for (i=0; i<elLength; i++)
{
var type = form.elements[i].type;
if ((type=="checkbox" && form.elements[i].checked) && !(form.elements[i].disabled)){
portNo[a]=i+1;
a++;
}
}
}else{
for (i=0; i<elLength; i++){
var type = form.elements[i].type;
if ((type=="checkbox" && form.elements[i].checked) && !(form.elements[i].disabled)){
portNo[0]=i+1.1;
portNo[1]=i+1.2;
a=2;
}
}
}
alert('function called');
if (a<2) {
alert ("Please Select Ports");
}else{
alert('function called11111111111111111');
/*executed successfully */
/*NONE OF THE BELOW CODE IS BEING EXECUTED IN FIREFOX*/
window.opener.document.forms[0].getElementById('P1').value =portNo[0];
window.opener.document.forms[0].getElementById('P2').value =portNo[1];
window.opener.document.forms[0].getElementById('P11').value =portNo[0];
window.opener.document.forms[0].getElementById('P21').value =portNo[1];
/* I found following three solutions on internet and tried all those but none of them working*/
/* 1 */
window.setTimeout("window.close()", 1)
/* 2 */
window.close(); /* tested not working*/
/* 3 */
var win=window.open("","_self");
win.close();
}
}
Moreover I found some where to set dom.allow_scripts_to_close_windows, can anyone guide me how to set this one.
For reference following is version of my firefox:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7 (.NET CLR 3.5.30729)
I hope I am making a mistake some where.
Firstly I know this issue has been addresses a lot already but as a newbie to HTML and Web Development I am unable to get the idea.
according to documentations and solutions proposed on different forums a popup or child window can be only closed using window.close() if it is opened via window.open() function.
Below is my code for opening the popup:
function getPorts(form){
var odfid = form.cmbodf.options[form.cmbodf.options.selectedIndex].value;
window.open('odfPorts.php?id='+odfid,'popuppage','width=515,titlebar=0,title=Select ODF,toolbar=0,resizable=0,scrollbars=no,height=500,top=150,left=500');
}
hence I am using window.open() to open window, ideally it should be closed using window.close().
Following is my code to close the pop up(it is validating some check boxes status and passing values to parent form and then is supposed to be closed)
function CheckCheckboxes(form, ot){
var elLength = form.elements.length;
var portNo=new Array(2);
var a=0;
if (ot==1){
for (i=0; i<elLength; i++)
{
var type = form.elements[i].type;
if ((type=="checkbox" && form.elements[i].checked) && !(form.elements[i].disabled)){
portNo[a]=i+1;
a++;
}
}
}else{
for (i=0; i<elLength; i++){
var type = form.elements[i].type;
if ((type=="checkbox" && form.elements[i].checked) && !(form.elements[i].disabled)){
portNo[0]=i+1.1;
portNo[1]=i+1.2;
a=2;
}
}
}
alert('function called');
if (a<2) {
alert ("Please Select Ports");
}else{
alert('function called11111111111111111');
/*executed successfully */
/*NONE OF THE BELOW CODE IS BEING EXECUTED IN FIREFOX*/
window.opener.document.forms[0].getElementById('P1').value =portNo[0];
window.opener.document.forms[0].getElementById('P2').value =portNo[1];
window.opener.document.forms[0].getElementById('P11').value =portNo[0];
window.opener.document.forms[0].getElementById('P21').value =portNo[1];
/* I found following three solutions on internet and tried all those but none of them working*/
/* 1 */
window.setTimeout("window.close()", 1)
/* 2 */
window.close(); /* tested not working*/
/* 3 */
var win=window.open("","_self");
win.close();
}
}
Moreover I found some where to set dom.allow_scripts_to_close_windows, can anyone guide me how to set this one.
For reference following is version of my firefox:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7 (.NET CLR 3.5.30729)
I hope I am making a mistake some where.