0

i tried so many codes, but i can't find it.

I want to load a website with webview. Before i show the website, i will change the CSS file path with an another css file on the Webserver.

for example: change this...

<link rel="stylesheet" href="css/styleLight.css" type="text/css" />

with this...

<link rel="stylesheet" href="css/styleDark.css" type="text/css" />

And how can i change for example the div id? On the website, there is a

<div id="light1">

how can i find this div and change his id to for example to

<div id="lightGreen">

2 Answers 2

1

You could use HttpUrlConnection to make the HTTP request, and get the HTML. You can then make any chances you like to the HTML, and load it into the WebView with WebView.loadData().

You can then intercept any links that are tapped using this form of handler:

    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView wv, String url) {
            Log.e("Test", "URL Clicked : " + url);
            // Request the HTML page here, then load into WebView
            return true;
        }
    });
Sign up to request clarification or add additional context in comments.

Comments

1

You could download the html via normal download methods (outside of the WebView), then change the code by html.replaceAll(...), then use the WebView to load the changed data using the website you got the html from as the BaseUrl.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.