如何提供将页面下载为完整 HTML 文件的选项(使用 JS/CSS 重新格式化和设计样式后)
我有一个网页,是通过使用 PHP 从数据库中提取字段并在 HTML 中设置它们来生成的。
加载此页面后,我使用 JavaScript 组合(我之前问过)和 CSS 来重新格式化和设计页面,使其更加清晰。
我现在需要的是为用户提供一种将呈现的页面(在 javascript/css 操作页面之后)作为整个 HTML 文件下载的方法。
我的能力还不够。有人可以帮忙吗?
我遇到的问题包括:
- 在浏览器中使用“保存”或“另存为”对话框仅保存 PHP 拉取的原始 HTML。我最终不得不“检查元素”并从开发人员视图中复制渲染的 HTML。
- 我添加的 CSS 和 JS 是在客户端完成的,而 PHP 需要一些时间来加载(不在我手中)。这个问题的解决方案需要能够在客户端或单独的站点/服务器上完成。
帮助?
I have a webpage that is generated by using PHP to pull fields from a database and set them in HTML.
Once this page loads, I use a combination of javascript (which I asked about before) and CSS to reformat and style the page to be more legible.
What I need now is provide a way for the user to download the rendered page (after the javascript/css manipulates the page) as a whole HTML file.
And I'm coming up short. Can some one help?
Problems I'm encountering include:
- using "Save" or "Save as" dialogs in the browser save only the original HTML as pulled by the PHP. I end up having to "Inspect element" and copy the rendered HTML from the developer view.
- The CSS and JS that I'm adding are done on the client-side, and the PHP takes a little while to load (out of my hands). A solution to this question will need to be able to be done on either the client-side, or on a separate site/server.
Help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在自己的服务器上使用服务器端代理(例如 PHP Web 代理)来自源服务器的未格式化的 html 页面,在您的服务器上重新格式化,然后以您想要保存的状态将其发送到浏览器。
You can use a server side proxy on your own server (eg. PHP Web Proxy) which grabs the unformatted html page in question from the source server, reformats it on your server, and then sends it to the browser in the state you want to save.
我从来不需要将其保存为文件,但当您看不到完整的渲染页面时,尤其是使用 Jscripts 时,进行故障排除会很麻烦。 “检查元素”是迄今为止我用来查看渲染页面的唯一解决方案。
还有一个名为 crowbar 的工具,我从未真正尝试过它,因为出于故障排除目的“检查元素”这就是我所需要的。
我不确定你想要什么 CSS。样式是无法真正保存的视觉元素。
I never had the need to save it as a file but for troubleshooting it is cumbersome when you don's see the complete rendered page, especially with Jscripts. "Inspect element" is the only solution I have used so far to see rendered page.
There is also a tool called crowbar which I have never really tried because for troubleshooting purposes "Inspect element" was all I ever needed.
I am not sure what you want with CSS. Styles are visual element which cannot really be saved.