问题描述
我有一个自定义的Webview设置,该设置运行良好,但我希望能够:
I'm got a custom webview setup which is working pretty well, but I'd like to be able to either:
1,更改url哈希,而不会在webview重新加载页面(这会丢失我的js应用程序的状态)
1, change the url hash without the webview reloading the page (it would lose the state of my js app)
2,从android内调用一些位于我网页内的js.不幸的是,我无法更改网站内的任何JS,因此无法自定义编写任何JS来放置在网站上,尤其是针对这份工作,我唯一能控制的就是Android应用程序.
2, call some js that sits within my web page from within android. I can't change any JS within the site, unfortunately, so can't custom write any js to put on the site especially for the job, the only stuff I have control over is the Android app.
有人能想到一种方法来做这两种方法吗?
Can anyone think of a way of doing either of these?
谢谢.
M
推荐答案
对于#2,您的Activity可以调用JavaScript方法.您所要做的就是通过适当的JavaScript调用来调用loadUrl方法:
For #2, your Activity can invoke JavaScript methods. All you have to do is call the loadUrl method with the appropriate JavaScript call:
mWebView.loadUrl("javascript:wave()");
发件人: http://developer.android.com/resources/articles/using-webviews.html
这篇关于更改Android Webview哈希而不重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!