At the beginning, I wanted to use the simplest method to achieve
let test = window.open('www.baidu.com')
test.onload = function () {
test.document.title = menu.menuName
}
or
let test = window.open('www.baidu.com')
setTimeout(()=>{
test.document.title = menu.menuName
})
But there will be cross-domain problems, and the title cannot be modified
In order to solve the cross-domain problem and realize the requirement of modifying the title, use iframe to realize
openNewWindow(path, name);
function openNewWindow(url, title) {
const win = window.open('about:blank');
win.document.title = title;
const iframe = document.createElement('iframe');
iframe.src = url;
iframe.style.width = '100%';
iframe.style.height = '100vh';
iframe.style.margin = '0';
iframe.style.padding = '0';
iframe.style.overflow = 'hidden';
iframe.style.border = 'none';
win.document.body.style.margin = '0';
win.document.body.appendChild(iframe);
}
Use this method to successfully implement the need to change the browser title and solve cross-domain problems