I need to display a table in a new window. when I click on a button, I got the values displayed in the same window but in a fresh page. I want the values in a new window instead of same window but in a fresh page. The below function gives the table for an array called num which is in the same htm file where are all the other functions are. As I need to use this num Array, I cannot write the code in a new file and call the url in the window.open method. Is there a way where I could write the code for the new window in the same htm file and just make the values display in a new window when I click the button. I tried window.open but that it not working. Could some one help me with this.

num=new Array();
function display(){
for(var i=0;i<data.length;i++)
var str = num[i].toString();
var strSplit =  str.split(",");
document.write("<table border='1'>");
for(var j=0;j<strSplit.length;j++)


<input type="button" name="entries" value="Display" onClick="display()">