Skip to content
Advertisement

Use document.write() to write the result in a separate page

I am writing an html code into javascript using document.write().

But the result came in the same page, I want to display the result in a separate page.

document.write('<table width="1000" border="1">');
document.write('<tr width="1000">'); 
document.write('<td width="100" bgcolor="#D8D8D8">Country</td>');
document.write('<td width="100" bgcolor="#D8D8D8">MCC</td>');
document.write('<td width="100" bgcolor="#D8D8D8">MNC</td>');
document.write('<td width="100" bgcolor="#D8D8D8">Network</td>');
document.write('<td width="100" bgcolor="#D8D8D8">Old Price</td>');
document.write('<td width="100" bgcolor="#D8D8D8">Current Price</td>');
document.write('<td width="100" bgcolor="#D8D8D8">Effective</td>');
document.write('<td width="100" bgcolor="#D8D8D8">Status</td>');
document.write('</tr>'); 
document.write('</table>');

So this table is being displayed in the webpage, I want this result to be displayed in another webpage.

Advertisement

Answer

Try this

var doc =window.open('','mydoc',
  'width=350,height=250'
   +',menubar=0'
   +',toolbar=1'
   +',status=0'
   +',scrollbars=1'
   +',resizable=1');
 doc.document.writeln(
  '<html><head><title>doc</title></head>'
   +'<body >'
   +'something'
   +'</body></html>'
 );
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement