Reputation: 25008
I want to customize the display of my html, using window.open()
. I wrote the code below, and got the output as per the screen shot attached.
My points are:
resizable
though i used resizable=no
bar title
untitled
by report
:var report = window.open('', '_blank', 'title="Report",toolbar=0, top=500,left=500, width=200,height=100,resizable=no,scrollbars=no, menubar=no, location=no, status=no');
report.document.body.innerHTML = text;
Upvotes: 1
Views: 3092
Reputation: 25008
Thanks for @Will and @GerardCuadras
Both answers are workable, so not sure which to accept as correct one, i voted up for both of them.
report.document.title = 'My customs Report';
report.document.body.innerHTML = text;
or
report.document.body.innerHTML = '<title>My customs Report</title>';
report.document.body.innerHTML += text;
Upvotes: 1
Reputation: 1654
If you want a title to appear in the new window just set the title
tag in your text
inside the <head>
.
<title>Title you want</title>
Example:
var report = window.open('', '_blank', 'title="Report",toolbar=0, top=500,left=500, width=200,height=100,resizable=no,scrollbars=no, menubar=no, location=no, status=no');
report.document.write("<html><head><title>TEST</title></head></html>");
Notice that I used document.write()
.
Also, in modern browser is not permitted to hide the url bar, you can find more info here.
The resize option has also a bug. Check this answer about disabling resize of new windows.
Upvotes: 4
Reputation: 41
var report = window.open('', '_blank', 'title="Report",toolbar=0, top=500,left=500, width=200,height=100,resizable=no,scrollbars=no, menubar=no, location=no, status=no');
report.document.body.innerHTML = text;
**report.document.title = 'custom one';**
Upvotes: -1