<body></body>
<script>
var height = 20, width = 20, newRow, newCell;
var tbl = document.createElement('table');
for (var line=0;line < height;line++){
newRow = document.createElement('tr');
for(var col=0;col<width;col++){
newCell= document.createElement('td');
if(line==0||line==height-1||col==0||col==width-1|| (line==col) || (width-1-col==line)) {newCell.textContent = '#'; }
newRow.appendChild(newCell);
}
tbl.appendChild(newRow);
}
document.querySelector('body').appendChild(tbl);
</script>