ravedadave Posted July 21, 2020 Posted July 21, 2020 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. Quote
Sherzod Posted July 21, 2020 Posted July 21, 2020 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() }); } Quote
ravedadave Posted July 27, 2020 Author Posted July 27, 2020 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. 1 Quote
Point Posted November 6, 2021 Posted November 6, 2021 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? Quote
Sherzod Posted November 6, 2021 Posted November 6, 2021 Hi @Popo And if used without modification, does it always work? Quote
Point Posted November 6, 2021 Posted November 6, 2021 Yes, I tried to click several url link in unidbhtmlmemo, work nice Quote
Point Posted November 6, 2021 Posted November 6, 2021 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. Quote
edbuescher Posted April 8, 2022 Posted April 8, 2022 Try setting the TUniHTMLMemo to ReadOnly. This disables links in my code for all the links in that HTMLMemo Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.