Page 1 of 1

Best replacement for <a href="javascript...." in HTML area?

PostPosted: Wed Jul 04, 2018 11:29 am
by drookwood
So I'm finally moving from Servoy 5 to 8!!

In 5 I have been using...
Code: Select all
<html><a href="javascript:globals.myMethod()">ClickMe</a></html>

...to trigger methods from within HTML areas but these no longer seem to work. What is the best replacement for this code in 8?

Re: Best replacement for <a href="javascript...." in HTML ar

PostPosted: Wed Jul 04, 2018 12:17 pm
by ROCLASI
Hi David,

By default Servoy doesn't trust HTML like that anymore. You can make it trust that specific element by adding the following code to your onLoad event:

Code: Select all
elements.NameOfElement.putClientProperty(APP_UI_PROPERTY.TRUST_DATA_AS_HTML, true);


Hope this helps.

Re: Best replacement for <a href="javascript...." in HTML ar

PostPosted: Wed Jul 04, 2018 2:18 pm
by drookwood
Hi Robert,

That's perfect - seems to work fine! Many thanks

Dave

Re: Best replacement for <a href="javascript...." in HTML ar

PostPosted: Fri Jul 20, 2018 12:03 pm
by rgansevles
When this TRUST_DATA_AS_HTML setting is used, make sure that all data in the html is static (like in your example) or from a source that cannot be modified by users, otherwise you would be vulnerable for a Cross-site scriping (XSS) attack.

Re: Best replacement for <a href="javascript...." in HTML ar

PostPosted: Fri Jul 20, 2018 3:52 pm
by drookwood
Appreciate the advice Rob - thanks