Gas
Gas

Reputation: 13

Change the title of window.open

I have a window.open function call on click, which opens an .swf albumplayer.

var win = null;
function NewWindow(wizpage, wizname, w, h, scroll){
LeftPosition = (screen.width) ? (screen.width-w)-8 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height=' + h + ',width=' + w + ',top= 100,' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable';
win = window.open(wizpage, wizname, settings);
} 

I would want to change the title of the opened window, that it has some meaningful title (a constant 'Album Player' or something would be fine), so that doesn't use the default filename/application-shockwave... text.

Thanks for the help.

Upvotes: 0

Views: 16797

Answers (3)

JJ Jasper Loubser
JJ Jasper Loubser

Reputation: 66

 function fnDurationPrint(displayText, dateText) {
             var WindowObject = window.open('', "DurationText", "width=430,height=250,top=200,left=250,toolbars=no,scrollbars=yes,status=no,resizable=no");
             WindowObject.document.writeln("<li>" + displayText + "</li>");
             WindowObject.document.title = "Duration Text of " + dateText;
         }

//WindowObject.document.title = must always be last after all code in javascript function

Upvotes: 0

Roman
Roman

Reputation: 101

Then put it to onload event:

win.onload = function() { this.document.title = "your new title"; }

Upvotes: 10

John Hartsock
John Hartsock

Reputation: 86902

Try this

var win = null;
function NewWindow(wizpage, wizname, w, h, scroll){
  LeftPosition = (screen.width) ? (screen.width-w)-8 : 0;
  TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
  settings = 'height=' + h + ',width=' + w + ',top= 100,' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable';
  win = window.open(wizpage, wizname, settings);
  win.document.title = "your new title";
} 

Upvotes: 2

Related Questions