javascriptjqueryhtmlhttpweb

Force a browser to download an BIG HTML file to disk and open it


Task: I have a huge html file that is placed on server, I want to show it to the user by click of an URL.

Issue: As this file is huge, On click of the URL the browser doesn't render the page in time*(Records get appended continuously while the vertical scroll bar size diminishes, user is not able to do anything but see the first few records)* and the default spinner of the browser spins endlessly.


Can this be achieve this way, if yes, how?---> On click of the "link", the html file should get downloaded on client machine first, then viewed on client browser window from his local system not from URL directly(maybe in a iframe or something).

EDIT loading 500 MB of HTML was asking a lot of a browser.

Work around Since generated htmls files were huge, we converted htmls files to pdf format. Later, used browser's default pdf viewer capability to view the data on browser window itself or simply downloaded the pdf file onto the disk.


Solution

  • No, there is no way to force a browser to download an HTML file to disk and open it.

    In practical terms, a 500+ MB HTML file will never be readable -- loading it requires much more memory than is available to a web browser. Downloading it won't help. You need to break it up into smaller documents.