wexond / browser-base

Modern and feature-rich web browser base based on Electron
https://wexond.net
2.68k stars 406 forks source link

When opening a new tab, using document.write(str) will cause the function to be unavailable #604

Closed caimingxue51 closed 3 years ago

caimingxue51 commented 3 years ago

Bug description

When encountering the following code:

 newPrint = window.open('');
  newPrint.document.write('<script>window.onload = function(){window.print();}</script>');
  newPrint.document.write(str);
  newPrint.document.close();

// str is html script code

this.webContents.addListener( 'new-window', (e, url, frameName, disposition) => { ... else if (disposition === 'foreground-tab') { e.preventDefault(); this.window.viewManager.create({ url, active: true }, true); }

The new tab cannot display the content of the webpage.

To Reproduce

Expected behavior

Screenshots

Details:

Additional context