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

Questions and answers for designing and implementing forms in Servoy

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

Postby drookwood » Wed Jul 04, 2018 11:29 am

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?
David Rookwood

SAN Developer
drookwood
 
Posts: 262
Joined: Tue Nov 11, 2003 7:08 pm
Location: Somerset, UK

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

Postby ROCLASI » Wed Jul 04, 2018 12:17 pm

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.
Robert Ivens
ROCLASI Software Solutions / JBS Group, Partner
SAN Developer / Servoy Valued Professional / Servoy Certified Developer
Twitter: @roclasi / @servoyforge
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5284
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

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

Postby drookwood » Wed Jul 04, 2018 2:18 pm

Hi Robert,

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

Dave
David Rookwood

SAN Developer
drookwood
 
Posts: 262
Joined: Tue Nov 11, 2003 7:08 pm
Location: Somerset, UK

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

Postby rgansevles » Fri Jul 20, 2018 12:03 pm

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.
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1867
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

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

Postby drookwood » Fri Jul 20, 2018 3:52 pm

Appreciate the advice Rob - thanks
David Rookwood

SAN Developer
drookwood
 
Posts: 262
Joined: Tue Nov 11, 2003 7:08 pm
Location: Somerset, UK


Return to Forms

Who is online

Users browsing this forum: No registered users and 0 guests