Skip to Content
avatar image
Former Member

How to make url clickable in textarea/feedlistitem

Hi,

Is there someone who knows how I can search for url's in a textarea of feedlistitem and make them clickable?

I already tried this, but the loop doesn't work for me...

http://stackoverflow.com/questions/1500260/detect-urls-in-text-with-javascript

Regards,

RW

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 05, 2014 at 03:51 PM

    Is the issue that you can't add the HTML syntax or the RegEx doesn't work? I believe for security reasons the controls escape the HTML to ensure you can't inject any harmful code for XSS attacks.

    https://sapui5.hana.ondemand.com/sdk/#docs/guide/4de64e2e191f4a7297d4fd2d1e233a2d.html

    The RenderManager writeAttributeEscape function calls jQuery.sap.escapeHTML

    Regards,

    Jason

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      I guess you could extend the controls and implement your own renderer or onAfterRendering method to add the link HTML. However if you are relying on users entering the text, I think you would need to still perform some validation of the URL to ensure that you don't introduce any cross scripting security issues.

      Regards,

      Jason

  • avatar image
    Former Member
    Sep 12, 2014 at 11:55 AM

    Thanks guys, I got it working. I'll probably create a document about this, because I think this might be helpfull for other users to.

    What I did was:

    1: in the updateFinished event from my sap.m.list I call a function 'createURL'.

    2. In the 'createURL' function I loop through all the objects of the same div class

    3. Get the plain tekst with the html() function

    4. Use autolinker (gregjacobs/Autolinker.js · GitHub ) to detect every url and create the a href tags.

    5. replace the old html content with the new

    The next thing I'll so is set up the validation.

    Kind regards,

    RW


    pastedImage_0.png (37.3 kB)
    Add comment
    10|10000 characters needed characters exceeded