How to customize the title of my browser window

2.5k Views Asked by At

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:

  1. I found the window to be resizable though i used resizable=no
  2. how to hide the bar title
  3. How to add my customs title to the form/page, I want to replace the 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;

enter image description here

3

There are 3 best solutions below

0
On BEST ANSWER

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.

0
On
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';**
2
On

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;