如何在自定义高度和宽度的新弹出窗口上更改窗口标题

How to change window title on a new popup window with custom height and width

本文关键字:窗口 新弹出 窗口标题 自定义 高度      更新时间:2023-09-26

下面是我的代码使用一个onclick与target="popup",我如何改变新的弹出窗口的标题?

<a href="#" target="popup" 
  onclick="window.open('http://s.jiathis.com/qrcode.php?url=http%3A%2F%2Ftest12345.com','popup','width=220,height=220,scrollbars=no,resizable=no'); return false;">Open new window</a>

您需要保持对新打开的窗口的引用:

var winRef = window.open(...);
winRef.document.title = 'Custom title';

弹出必须有相同的起源(域名)作为打开器,或至少有适当的CORS头集。下面是一个有效的例子:https://jsfiddle.net/c7x7ajv2/