admin管理员组文章数量:1384563
I have a very big HTML page
with many large tables.
I have tried to export the tables to excel
and succeeded. But when dealing with 200K+ rows
in a table, the browser crashes (Chrome and IE).
So, I have decided to save the entire page locally.
Can it be done?
Thanks
I have a very big HTML page
with many large tables.
I have tried to export the tables to excel
and succeeded. But when dealing with 200K+ rows
in a table, the browser crashes (Chrome and IE).
So, I have decided to save the entire page locally.
Can it be done?
Thanks
Share Improve this question edited Jan 5, 2017 at 13:09 GôTô 8,0633 gold badges36 silver badges45 bronze badges asked Jan 5, 2017 at 12:40 ZarofZarof 1172 silver badges12 bronze badges 4- 2 File -> Save Page As? – Serg Chernata Commented Jan 5, 2017 at 12:41
- what exactly do you want to save? just the raw HTML code? or the whole page including images, css, js? – vsync Commented Jan 5, 2017 at 12:56
- Whole page locally.. – Zarof Commented Jan 5, 2017 at 13:03
- @SergChernata exactly the same as File -> Save Page As... – Zarof Commented Jan 5, 2017 at 13:09
4 Answers
Reset to default 1If you need a download button that anyone can use on your site to save a file, use the download
attribute.
<a href='link.html' download>text</a>
I suppose that the data that is in these tables is loaded from your server somewhere. Wouldn't it be better to create a downloadlink to an action on your server that creates these files instead of creating the files based on your html page?
One solution is to load the page in your browser and then go to File > Save As. This will open a dialoge that allows you to save the page as an html type file.
However if the webpage is so large that the browser cannot load it, use a tool like wget on linux to pull the entire page down without using a browser. After installing wget on a linux distribution, use it like so
wget http://www.example./path/to/file.html
This mand will download the file to the current directory with name file.html
If you also want to download any included files in file.html
(ie css or js files). Include the flags -p
and -k
.
I created a file called download-page-test.html as seen below.
<html>
<head>
<title>Template</title>
<link href="https://maxcdn.bootstrapcdn./bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<h1>Look at this page.</h1>
<h1>It's so plain!</h1>
<a class="btn btn-primary" href='/download-page-test.html' download>Click Here to Download</a>
</body>
When the user clicks on the word "text", the browser downloads the same exact file that is served to the browser as well as the JS/CSS for the page (Granted you don't move/delete the external resources). Note: I used BootStrap to make it look a bit nicer.
This solution is for a page that loads in the browser successfully and the user wants a copy.
本文标签: javascripthow can i save the current HTML page locally via a button on pageStack Overflow
版权声明:本文标题:javascript - how can i save the current HTML page locally via a button on page? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744528201a2610870.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论