Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
function linkClick(e) {
  alert(e.target.href);
}

function setDefaultLinkHandlers(){
  links = document.getElementsByTagName('a');
  for (i = 0; i < links.length; i++)
  links[i].addEventListener('click', linkClick, false);
}

document.onload=setDefaultLinkHandlers();

This is JavaScript

String Url = "http://dev.taxmann.com/actruleservice/ActRuleService.asmx/GetFileHTML?FileID_or_FullPath=102120000000025184";
String htmlResp = getStringPage(Url);

WebSettings webSettings = webview.getSettings();

String k = Html.fromHtml((String) htmlResp).toString().replace(");'", "");

Here k is String where am getting HTML, I have to add that JavaScript in this HTML. Can anyone tell me how I will add this?

share|improve this question

1 Answer

up vote 0 down vote accepted
String myJavascript = "<script>"+"your javascript here"+"</script></head>";

htmlResp = htmlResp.replace("</head>", myJavascript);

String k = ....
share|improve this answer
String myJavascript = "<script>"+"function linkClick(e) { alert(e.target.href);}function setDefaultLinkHandlers(){ links = document.getElementsByTagName('a');for (i = 0; i < links.length; i++) links[i].addEventListener('click', linkClick, false); } document.onload=setDefaultLinkHandlers();"+"</script></head>"; It Should Like this Arjun – Priya Dash Apr 24 at 5:25
Yes. Try that and let me know if that doesnt work. – Arjun Rao Apr 24 at 5:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.