我使用以下代码打开新的弹出窗口。
var sFeatures = 'toolbar=0, directories=0, location=0, menubar=0, status=0, titlebar=0, scrollbars=0, resizable=0'+ ', width=' + screen.availWidth + ', height=' + (screen.availHeight - 40);
var newWin = window.open(url, '_blank', sFeatures, true);
弹出的标题有一个问题。在页面加载之前,显示的是url而不是标题。当页面加载后,标题被设置。我需要在页面加载前更改标题。我试过下面的代码,但它不工作。
newWin.document.title = 'Anything';
你使用的是哪个浏览器?你也可以尝试使用
newWin.onload = function () { this.document.title = "Anything"; }
但我认为在页面加载前不能更改标题。onload
也会等待一切加载完毕。实际的标题来自于 <title>
元素,如果页面没有完全加载,那么你就不能在该元素上运行。