更改window.open的标题

时间:2010-11-09 22:04:18

标签: javascript

我点击了一个window.open函数调用,打开一个.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);
} 

我想要更改已打开窗口的标题,它有一些有意义的标题(一个常量'专辑播放器'或者其他东西会很好),所以不使用默认文件名/ application-shockwave .. .text。

感谢您的帮助。

3 个答案:

答案 0 :(得分:8)

然后把它放到onload事件:

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

答案 1 :(得分:2)

试试这个

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";
} 

答案 2 :(得分:0)

 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 =必须始终是javascript函数中所有代码的最后一个

相关问题