Adding colour to a Javascript variable text in JS code in workflow | Community
Skip to main content
Level 3
October 9, 2023
Solved

Adding colour to a Javascript variable text in JS code in workflow

  • October 9, 2023
  • 1 reply
  • 966 views

Hi All,

 

I have a variable say "xyz" in javascript code in workflow and want to output colour to the variable text that starts with a bullet point. <style> tag soes not work in JS, How can I include colour to only the bullet point. example code is given below:

 

var xyz= "<style="font-size: 14px; color:#762A91;">•</style> Output text <br><br>";

 

Thank you,

Rutuja Kelkar

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Marcel_Szimonisz

Hello @rut7 ,

How do you print this code? Is it with <%= xyz %>?

This will HTML encode your code, and also your variable is wrongly formatted, which should throw an error, as you need to escape double quotes.

To prevent it from escaping HTML, you need to use document.write I do not know if that works inside delivery. I am sure it works in webapp:



 

 

<% var xyz= '<style="font-size: 14px; color:#762A91;">•</style> Output text <br><br>'; //i have replaced " with ' or you need to escape " with \" when the string is surrounded with "" document.write(xyz); %>

 

 

 

 

 

Marcel Szimonisz

MarTech Consultant
for more tips visit my blog
https://www.martechnotes.com/

1 reply

Marcel_Szimonisz
Community Advisor
Marcel_SzimoniszCommunity AdvisorAccepted solution
Community Advisor
October 9, 2023

Hello @rut7 ,

How do you print this code? Is it with <%= xyz %>?

This will HTML encode your code, and also your variable is wrongly formatted, which should throw an error, as you need to escape double quotes.

To prevent it from escaping HTML, you need to use document.write I do not know if that works inside delivery. I am sure it works in webapp:



 

 

<% var xyz= '<style="font-size: 14px; color:#762A91;">•</style> Output text <br><br>'; //i have replaced " with ' or you need to escape " with \" when the string is surrounded with "" document.write(xyz); %>

 

 

 

 

 

Marcel Szimonisz

MarTech Consultant
for more tips visit my blog
https://www.martechnotes.com/

Sukrity_Wadhwa
Community Manager
Community Manager
October 31, 2023

Hi @rut7,

Was the given solution helpful to resolve your query or do you still need more help here? Do let us know.

Thanks!

Sukrity Wadhwa