how to detect url inside a textarea

chrome can detect url inside a textarea
select an url – right click – and you’ll see – go to ...
so I hope it is possible similar by clicking inside an url – get the href in console
the code below is probably a start but it results in entire body as selection
any idea?

document.onselectionchange = () => {
    var selection = window.getSelection();
    console.log(selection.anchorNode);
};
#ed{
display:block;
width:100%;
height:50vh;
padding:9px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea id='ed'>
lorem ipsum
https://google.com
dolor sit
</textarea>

66 thoughts on “how to detect url inside a textarea”

  1. Pingback: womens viagra
  2. Pingback: cheapest viagra
  3. Pingback: cheap viagra
  4. Pingback: viagra pills
  5. Pingback: cialis 24 hours
  6. Pingback: sildenafil online
  7. Pingback: www.cialisgap.com

Leave a Comment