0

guys. I m trying developing a simple youtube mp3 download project. I m using webview. I m loading this link to my webview "http://www.youtube-mp3.org/get?ab=128&video_id=KMU0tzLwhbE&h=5671e7d33d4eccb5b89ea8f54d9911d4&r=1387110278658.1527580295". Then I want to click programatically the "Download" link. I've tried many methods but didn't work. The code below which I inserted works on Chrome Console . But don't work in android app . Could 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);"+
                        "})()");
1
  • Yes I found the solution.And I finished my application.What is your problem?I did click event like this ;web.loadUrl("javascript:document.getElementsByClassName('example')[0].click();"); Commented Jan 6, 2015 at 16:43

2 Answers 2

2

Already I had made Webview.getSettings.setJavaScriptEnabled(true);

And I found solution;

Button Click event must be like this

web.loadUrl("javascript:document.getElementsByClassName('example')[0].click();"‌​);

Sign up to request clarification or add additional context in comments.

Comments

0

Make sure you javascript enabled on your webview:

Webview.getSettings.setJavaScriptEnabled(true);

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.