【问题标题】:Is it possible to inject html into a webview more than once?是否可以多次将 html 注入到 webview 中?
【发布时间】:2014-12-24 17:19:58
【问题描述】:

我想多次将 html 注入到同一个 Android webview 中。第一次调用注入一些 javascript,第二次调用注入 html 和更多 javascript。到目前为止,在我的尝试中,第二次注入会覆盖第一次。所以我想知道这是否可能?

【问题讨论】:

  • 您可以随时使用 loadurl("your javascript code here"); 调用 javascript 并添加更多 html,您必须调用 javascript 函数才能将其添加到某个类或 div 中,如果您 loadurl("html"); 则无论如何它都会覆盖你以前的 html。
  • 什么意思我只需要调用一个javascript函数?

标签: android android-webview


【解决方案1】:

您可以从 WebView 获取 html,然后根据需要进行更新。在这种情况下,您不会丢失 WebView 中的任何信息。

见:

Is it possible to get the HTML code from WebView

how to get html content from a webview?

【讨论】:

  • 所以你建议从 webview 中获取 html,根据需要更新它并将其注入回来?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-10
  • 1970-01-01
  • 2014-06-07
  • 2015-02-11
  • 1970-01-01
  • 2019-09-12
相关资源
最近更新 更多