View Full Version : changing popup window title

03-19-2004, 06:15 PM
I created a window using

var win = window.open(URL, name, features) ;

tried to do
win.document.title = 'new title' ;

got javascript 'Unspecified error'

How am I suppose to change the title in javascript???

Mr J
03-19-2004, 07:39 PM
It should work, what "features" have you specified?

03-19-2004, 08:12 PM
Possible fault is that you try and set the title before the document has loaded. Note I have never really tampered with popups so is just a guess.

03-19-2004, 08:13 PM
That feature does not work in any of the Mozilla browsers. You can only reference the document.title.

03-19-2004, 08:23 PM
Give this a shot:

try {
// should work w/ IE
win.document.title = 'new title';
} catch (err) {
try {
// should work with Gecko
win.defaultView.documentElement.title = 'new title';
} catch (err2) {
alert('I cannot set the title.');

Sorry, forgot to close the tag.

03-19-2004, 08:34 PM
unfortunately, I'm running currently on IE6. I'll try to delay the win.document.title and see if that works.

03-19-2004, 09:33 PM
Okay, if that won't work period, try this.

win = window.open(...);
win.setTitle = setTitle;
win.onload = function () {
document.title = 'new title';

Maybe that'll work?