I want to change the loading location when I tap the link on Android WebView.

Asked 1 years ago, Updated 1 years ago, 62 views

I would like to change the Uri tapped on the webView and load it.
Specifically, I would like to load the one with the JavaScript argument removed from the Uri link.
For example,

<a href="http://example.com/index.html?id=hoge">

In the case of html, I would like to have index.html read instead of index.html?id=hoge.How can I achieve this?

android android-webview

2022-09-30 21:19

1 Answers

If you remove the URL argument in Javascript: link.split('?') removes arguments from the best ?:

<body>
    <a href="http://example.com/index.html?id=hoge">link to example.com</a>
</body>
<script>
varlink = document.getElementsByTagName("a")[0].href;
document.getElementsByTagName("a")[0].href=link.split('?')[0];
</script>


2022-09-30 21:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.