有没有办法让一个web视图中的HTML在一个Android应用程序? [英] Is there a way to get the HTML in a webview in an Android app?
问题描述
有没有办法让一个web视图中的HTML在一个Android应用程序?我想preFER这通过一个简单的资源下载得到的HTML,尤其是如果我能得到的HTML被JavaScript生成。
例如,如果我想在访问我的Android应用程序,包括Web应用程序,如Gmail随机HTML文档,我将如何去了解这一切的URL列表?
Android的文件提出了警示,让JavaScript的访问应用程序,但我想也许一个解决办法是,如果可能的话,注入一些JavaScript代码到网页这在希望安全的方式与我的应用程序,然后进行通信(通过消息在我控制在JavaScript或类似的东西)网站路过或东西通过一个IFRAME。
任何一个有什么想法?
有没有办法让一个web视图中的HTML在一个Android应用程序?
不容易。 的javascript:
网址工作, addJavascriptInterface()
允许您设置了回调的JavaScript可以调用。您可以创建的Javascript由的JavaScript加载一个片段:
网址获得您的DOM,或走你的链接,什么列表,把结果发回给你通过回调对象,你通过 addJavascriptInterface注册()
。
Is there a way to get the HTML in a webview in an Android app? I would prefer this to getting the HTML via a simple resource download, especially if I can get HTML generated by JavaScript.
For example if I wanted a list of all URLs in a random HTML document accessible to my android application, including web apps such as gmail, how would I go about it?
The android documentation warns about letting JavaScript access the application, but I was thinking maybe a solution would be, if at all possible, to inject some JavaScript into the webpage which then communicates with my application in a hopefully safe way (via message passing or something through an iframe on a site that I control the javascript on or something similar).
Any one have any ideas?
Is there a way to get the HTML in a webview in an Android app?
Not easily. javascript:
URLs work, and addJavascriptInterface()
allows you to set up callbacks that the Javascript can call. You may be able to create a snippet of Javascript loaded by a javascript:
URL that obtains your DOM, or walks your list of links, or something, sending the results back to you via the callback object you registered via addJavascriptInterface()
.
这篇关于有没有办法让一个web视图中的HTML在一个Android应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!