给WebView中的url添加参数 [英] Add parameter to url in WebView
本文介绍了给WebView中的url添加参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,网页加载到 webview 中.使用 shouldOverrideUrlLoading()
我可以在同一网页视图中打开该页面上的链接.但是有没有办法在每次加载这个特定的 url 时在所有链接上附加一个像 &mode=app
这样的参数?所有带有例如的网址example.com
应该看起来像 example.com?mode=app
并且所有其他 url 应该保持原样.
In my app a webpage is loaded in a webview. With shouldOverrideUrlLoading()
I can open links on that page in the same webview. But is there a way to append on all links a parameter like &mode=app
every time when this specific url is loaded?
All urls with e.g. example.com
should look like example.com?mode=app
and all other urls should stay how they are.
这可能吗?
推荐答案
在你的方法中你可以尝试一下.
in your method you can try it.
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.equals("example.com") || url.equals("http://example.com")) {
url = url + "?mode=app";
}
view.loadUrl(url);
return true;
}
这篇关于给WebView中的url添加参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文