更改Android Webview哈希而不重新加载页面 [英] Changing the Android Webview hash without reloading page

查看:215
本文介绍了更改Android Webview哈希而不重新加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的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哈希而不重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆