Jump to content

TUniHtmlMemo Link Click


ravedadave

Recommended Posts

Hi All,

Is there a way to to disable the action of an end user clicking a link in a HTMLMemo.

For example the html content links to another site and the end user clicks the link currently the content of the HTMLMemo is redirected to that site, is there a way to supress it so it doesn't but still maintain the link content.

 

Thank You.

 

Dave.

Link to comment
Share on other sites

1 hour ago, ravedadave said:

For example the html content links to another site and the end user clicks the link currently the content of the HTMLMemo is redirected to that site, is there a way to supress it so it doesn't but still maintain the link content.

Hi,

You can try to use this approach.

UniHTMLMemo.ClientEvents.ExtEvents ->

function initialize(sender, eOpts)
{
    sender.iframeEl.dom.contentDocument.body.addEventListener('click', function(e) {
        e.preventDefault()
    });
}

 

Link to comment
Share on other sites

On 7/21/2020 at 4:53 PM, Sherzod said:

Hi,

You can try to use this approach.

UniHTMLMemo.ClientEvents.ExtEvents ->


function initialize(sender, eOpts)
{
    sender.iframeEl.dom.contentDocument.body.addEventListener('click', function(e) {
        e.preventDefault()
    });
}

 

Perfect! You are a legend, Thank You.

 

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Hi @Sherzod,

I modified the code above, so when i click the url link can open a new browser tab. after i implemented this code only works occasionally.

function initialize(sender, eOpts)
{
    sender.iframeEl.dom.contentDocument.body.addEventListener('click', function(e) {
      if (e.target.href !== undefined) {
         e.preventDefault();
         window.open(e.target.href, "_blank");
      };
    });
}

something wrong with my code?

Link to comment
Share on other sites

Hi Sherzod,

seem it didn't mistake in creating the url link, it is proven by using a right click, the link leads to the intended url.

After I reset the url link by deleting and recreate the url link, it worked fine. 

i don't know what caused it.

Many thanks for support.

Link to comment
Share on other sites

  • 5 months later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...