Dark_Shadow
12-13-2009, 05:37 PM
Hi! I have a problem with the function close();
The window does open but then it immediately closes by itself. I didn't even get to see the content and of course I didn't even click on the button "close the window!"
I want to be able to see the content of the page and when I click on the button, it will close the window. Thank you in advance for your help!
var window;
function newWindow(){
window=window.open("", "Results", "width=400, height=250");
window.document.write("<body><table>");
window.document.write("<h1 style='border-bottom-style: dotted; border-bottom-width: 1px;font: italic 16pt Times New Roman, sans-serif; color: navy;'>Survey's Results</h1>");
for(var i=0; i<tabVotes.length; i++){
window.document.writeln("<tr>");
window.document.writeln("<td style='text-align: center'>" + tabPeople[i] + "</td>");
window.document.writeln("<td style='text-align: center'>" + tabVotes[i] + " votes </td>");
window.document.writeln("</tr>");
}
window.document.writeln("</table>");
window.document.writeln("<input name='Close' type='button' value='Close the window' />");
window.document.getElementById('Close').onclick = window.close();
window.document.writeln("<br /><br />Thank you!");
window.document.writeln("</body>");
}
The window does open but then it immediately closes by itself. I didn't even get to see the content and of course I didn't even click on the button "close the window!"
I want to be able to see the content of the page and when I click on the button, it will close the window. Thank you in advance for your help!
var window;
function newWindow(){
window=window.open("", "Results", "width=400, height=250");
window.document.write("<body><table>");
window.document.write("<h1 style='border-bottom-style: dotted; border-bottom-width: 1px;font: italic 16pt Times New Roman, sans-serif; color: navy;'>Survey's Results</h1>");
for(var i=0; i<tabVotes.length; i++){
window.document.writeln("<tr>");
window.document.writeln("<td style='text-align: center'>" + tabPeople[i] + "</td>");
window.document.writeln("<td style='text-align: center'>" + tabVotes[i] + " votes </td>");
window.document.writeln("</tr>");
}
window.document.writeln("</table>");
window.document.writeln("<input name='Close' type='button' value='Close the window' />");
window.document.getElementById('Close').onclick = window.close();
window.document.writeln("<br /><br />Thank you!");
window.document.writeln("</body>");
}