Programmatically change Background Colour?

ewalsh-3688
ewalsh-3688 Community Member Posts: 20 ☆ Roadie ☆
edited November 12, 2020 in Lectora Online
Hi Lectora Online Rockstars ğŸŽ¸,

Does anyone know if it is possible to change the background colour of a title programmatically using an action or JavaScript? I'd like to be able to offer an option of changing the background colour to support learners who may have Dyslexia.

It looks like someone asked a similar question in 2009 but there were no responses 🙁 https://rockstars.elearningbrothers.com/discussion/271244/accessibility-issues

Thanks in advance 🙂

Comments

  • jholland
    jholland Rockstar Manager Posts: 35 eLearning ROCKSTAR Admin Team
    Hello. For a published course with a simple background, the tag background controls the color. You can add the following code to a button or item to change the CSS for the page's background color. You could create a button or other object with an action on it. For example, a button with a "On Mouse Click" trigger, and an action to "Run Javascript". Then place this code in the javascript box:

    triv$( 'body', getDisplayDocument() ).css("background-color","red");

    You can change the "red" to any valid CSS color, or use rgb() function in double quotes:

    triv$( 'body', getDisplayDocument() ).css("background-color","rgb(0,0,255)");.

    You could also change a background image with code like this on the "background-image" property.