Reputation: 23
I'm generating new a window with JavaScript using window.open
and putting some content in it.
How can i declare the <!DOCTYPE>
?
Upvotes: 2
Views: 3061
Reputation: 797
I don't think you can use window.open
alone for this but it seems you can do this with a little more coding.
Check out this similar question. I think you could easily adapt it to do what you're asking.
Add Content to new open window
Upvotes: 0
Reputation: 6764
It's not possible.
window.open just opens a new browser instance. It's the page's responsability, inside the popup, to declare its doctype.
Edit
Actually, I found this, but this example will only work if you're planning on overwriting the content of the newly opened window.
function openWin(){
var winTitle='blah';
var winBg='#FF0000';
var newWin=window.open('', '', 'height=130, width=160');
newWin.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>'+winTitle+'</title></head>');
newWin.document.write('<body bgColor="'+winBg+'"><img src="images/picture.jpg" border=0></body></html>');
newWin.document.close();
}
Upvotes: 1