javascript - android webview click html link programatically -
People I'm trying to develop a simple YouTube MP3 download project. I am using the webview I am loading this link on my webview "" Then I want to click the "download" link programmatically. I have tried many ways but did not work. The code below works on Chrome console. But do not work in the Android app Can you help me?
web.loadUrl ("Javascript: document.getElementById ('dl_link'). GetElementsByTagName ('A') [2]. Click ();");
web.loadUrl ("javascript: (function () {" + "l = document.getElementById ('dl_link'). GetElementsByTagName ('a') [2];" + "e = Document.createEvent ('HTMLEvents'); "+" e.initEvent ('click', true, true); "+" l.dispatchEvent (e); "+"}) () "); Ensure that you enable javascript on your webview:
Webview GetSettings.setJavaScriptEnabled (true);
Comments
Post a Comment