安卓:注入的Javascript到onPageFinished事件外的web视图 [英] Android: Injecting Javascript into a Webview outside the onPageFinished Event
问题描述
嘿专家,其实这是一个pretty的简单的问题......只是不知道答案。
我有一个Android应用程序,运行的WebView加载某个页面,也有部分应用程序中。
在一个特定的时刻,我想打电话给web视图页面内的JavaScript函数,但我想这样做的onPageFinished事件之外。
这可能吗?任何想法?
在此先感谢。
这可能吗?
当然。使用使用loadURL(JavaScript的:......);
,其中 ...
是什么的Javascript要在当前加载的网页的上下文中运行。它基本上是相同的把戏,小书签使用。
下面是一个简单的项目证明这一点,通过推GPS位置在为Javascript。
Hey experts, actually it's a pretty simple question...just don't know about the answer.
I have an Android app, running a WebView that loads a certain page, also part of the app.
At a given moment, i want to call a javascript function inside the WebView page, but i wanna do this outside the onPageFinished event.
Is that possible? Any ideas?
Thanks in advance.
Is that possible?
Sure. Use loadUrl("javascript:...");
, where the ...
is whatever Javascript you wish to run in the context of the currently-loaded Web page. It's basically the same trick that bookmarklets use.
Here is a sample project demonstrating this, by pushing a GPS location over to Javascript.
这篇关于安卓:注入的Javascript到onPageFinished事件外的web视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!