2

I want to execute a javascript on already loaded webpage in Webview. I am loading a new article webpage eg: www.techcrunch,com in webview. I want to run javascript on this already loaded webpage in Webview. This javascript is an external file in assets folder. The javascript basically extracts images from the tags in does some other processing in the html page. How can I execute this javascript on the already loaded www.techcrunch.com page?

Thanks,

1
  • I've never done any Android development, but I'm pretty confident there's no way to inject your own scripts into someone else's document in a Webview. That would be an ENORMOUS security problem. You're basically talking about a cross-site scripting (XSS) attack - regardless of the fact that your intentions aren't malicious. Commented Jun 26, 2012 at 5:17

1 Answer 1

3

It's the same like for any other web browser. Use the javascript protocol:

webview.loadUrl("javascript:alert('Example');");
Sign up to request clarification or add additional context in comments.

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.