Hi guys in my web app i wanted to print selected text(say here content in paragraph tag). How to do it in Android WebView, how to select text using JavaScript??
Thanks in advance..
Here is my JavaScript code
<script type="text/JavaScript">
function SelectText()
{
var txt = '';
if (window.getSelection)
{
txt = window.getSelection();
}
else if (document.getSelection)
{
txt = document.getSelection();
}
else if (document.selection)
{
txt = document.selection.createRange().text;
}
else return;
document.getElementById("demo").innerHTML= txt;
}
</script></head>
<body>
<p>Hi man how are you?? Hope your doing good..</p>
<p> id="demo"></p>
<button> onclick="SelectText()">Selected text</button>
</body>
</html>