将 HTML 从 WebView 保存到文档目录中的现有文件
我一直在编写一些加载和保存 HTML 文件的代码。我已经能够创建它们,但是在 WebView 中编辑它们后,我需要将 HTML 文件从 webView 保存回文档目录。但是我不确定如何创建 HTML 文件。我将不胜感激你的帮助。我有文档文件路径和标题。
I have been working on some code that loads and saves HTML files. I have been able to create them, but after they are edited in the WebView, I need to save an HTML file from the webView back to the documents directory. I am not sure how to create the HTML file however. I would appreciate your help. I have the document file path and title.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能想到的唯一方法是使用 javascript 提取 html。例如,如果您引用了名为 webView 的 UIWebView 对象,则以下内容将返回包含内部 html 的字符串:
然后您可以将其重新装回完整的 html 页面,javascript 将仅返回
< 中的内容;body>
标签。大概在加载然后编辑 html 页面的代码中,您可以知道并因此存储标记之外发生的任何特定信息,以便可以恢复它?
The only way I can think of doing this is with javascript to pull out the html. For example if you have a reference to your UIWebView object called webView the following would return a string containing the inner html:
You could then dress it back up to a complete html page, the javascript will only return the content within the
<body>
tags. Presumably within your code that loads and then edits the html page you can know, and therefore store, any specific information that occurred outside of the<body>
tags such that you can restore it?