1

I've been attempting to download a webpage directly using window.print() but it seems to skip the print window part. It does open the desired url, but refuse to load on the pdf print window and immediately closes the print window. Here's my code:

const onPrint = () => {
  const url = "https://www.google.com";
  window.open(url)?.print();
}

<a onClick={() => onPrint()}>Click me to download</a>

I also tried to use iframe but it says "google.com refused to connect", I'm aware that sites like Google, Yahoo, etc. won't allow iframes. I'm thinking of auto start download as it get to the external webpage but I'm not sure what should I do..

P/S: I'm using Reactjs to develop my webapp.

Falady
  • 124
  • 1
  • 15
  • Once you open a URL that belongs to a different site, your – Shreshth Mar 16 '22 at 06:40
  • 1
    Google blocks iframe. You can download websites by sshing into your server and using wget. – ethry Mar 16 '22 at 07:17

0 Answers0