0

I'm building a system where I'm asking user to enter the URL he wants, then I'm rendering this URL in an iframe but I want anyway to get the content of the iframe as the download page source feature when right clicking the page in the browser.

I'm also open to any other solution other than rendering in iframe.

georgeawg
  • 48,608
  • 13
  • 72
  • 95
Islam Taha
  • 11
  • 7

1 Answers1

1

Since the URL is arbitrary, you can't access the content of the frame with client-side JS.

Nor can you use fetch or XMLHttpRequest.

That leaves fetching it with server-side code.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • That's true, but the problem is that sometimes the page the client want to get to needs some sort of authentication, do you have any idea how can I get this using something like a reverse-proxy or something ? – Islam Taha Jul 29 '20 at 21:27
  • You can't, in the context of a normal webpage. A browser extension could be granted additional privileges. – Quentin Jul 29 '20 at 21:31